1 /* Regression test for PR middle-end/33826 */
2 /* Verify that recursive functions cannot be pure or const.  */
3 
4 /* { dg-do compile } */
5 /* { dg-require-effective-target nonpic } */
6 /* { dg-options "-O1 -fdump-tree-local-pure-const1 -fdump-ipa-pure-const" } */
7 
recurese1(int i)8 int recurese1 (int i)
9 {
10   return recurse1 (i+1);
11 }
12 
recurse2a(int i)13 int recurse2a (int i)
14 {
15   return recurse2b (i+1);
16 }
17 
recurse2b(int i)18 int recurse2b (int i)
19 {
20   return recurse2a (i+1);
21 }
22 
norecurse1a(int i)23 int norecurse1a (int i)
24 {
25   return norecurse1b (i+1);
26 }
27 
norecurse1b(int i)28 int norecurse1b (int i)
29 {
30   return i+1;
31 }
32 
33 /* { dg-final { scan-tree-dump "found to be const: norecurse1a" "local-pure-const1" } } */
34 /* { dg-final { scan-tree-dump "found to be const: norecurse1b" "local-pure-const1" } } */
35 /* { dg-final { scan-tree-dump-not "found to be pure: recurse1" "local-pure-const1" } } */
36 /* { dg-final { scan-tree-dump-not "found to be pure: recurse2a" "local-pure-const1" } } */
37 /* { dg-final { scan-tree-dump-not "found to be pure: recurse2b" "local-pure-const1" } } */
38 /* { dg-final { scan-tree-dump-not "found to be const: recurse1" "local-pure-const1" } } */
39 /* { dg-final { scan-tree-dump-not "found to be const: recurse2a" "local-pure-const1" } } */
40 /* { dg-final { scan-tree-dump-not "found to be const: recurse2b" "local-pure-const1" } } */
41 /* { dg-final { scan-ipa-dump-not "found to be pure: recurse1" "pure-const" } } */
42 /* { dg-final { scan-ipa-dump-not "found to be pure: recurse2a" "pure-const" } } */
43 /* { dg-final { scan-ipa-dump-not "found to be pure: recurse2b" "pure-const" } } */
44 /* { dg-final { scan-ipa-dump-not "found to be const: recurse1" "pure-const" } } */
45 /* { dg-final { scan-ipa-dump-not "found to be const: recurse2a" "pure-const" } } */
46 /* { dg-final { scan-ipa-dump-not "found to be const: recurse2b" "pure-const" } } */
47 /* { dg-final { cleanup-ipa-dump "pure-const" } } */
48 /* { dg-final { cleanup-tree-dump "local-pure-const1" } } */
49