| 1 |
struct st1; |
| 2 |
|
| 3 |
int foo (struct st1 *p); |
| 4 |
int bar (struct st1 *p); |
| 5 |
|
| 6 |
void test_1 (struct st1 *p) |
| 7 |
{ |
| 8 |
test_1 (p); /* { dg-warning "infinite recursion" } */ |
| 9 |
} |
| 10 |
|
| 11 |
void test_2_if (struct st1 *p) |
| 12 |
{ |
| 13 |
if (foo (p)) |
| 14 |
test_2_if (p); /* { dg-bogus "infinite recursion" } */ |
| 15 |
} |
| 16 |
|
| 17 |
void test_2_switch (struct st1 *p) |
| 18 |
{ |
| 19 |
switch (foo (p)) |
| 20 |
{ |
| 21 |
case 0 ... 9: |
| 22 |
test_2_switch (p); /* { dg-bogus "infinite recursion" } */ |
| 23 |
break; |
| 24 |
default: |
| 25 |
break; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
void test_2_if_compound (struct st1 *p) |
| 30 |
{ |
| 31 |
if ((foo (p) + bar (p)) >= 0) |
| 32 |
test_2_if_compound (p); /* { dg-bogus "infinite recursion" } */ |
| 33 |
} |
| 34 |
|
| 35 |
void test_3 (struct st1 *p) |
| 36 |
{ |
| 37 |
foo (p); |
| 38 |
test_3 (p); /* { dg-warning "infinite recursion" } */ |
| 39 |
/* The content of *p never affects control flow, so we should |
| 40 |
report this. */ |
| 41 |
} |
| 42 |
|
| 43 |
struct st2 |
| 44 |
{ |
| 45 |
int i; |
| 46 |
}; |
| 47 |
|
| 48 |
void test_4 (struct st2 *p) |
| 49 |
{ |
| 50 |
if (p->i > 0) |
| 51 |
test_4 (p); /* { dg-warning "infinite recursion" } */ |
| 52 |
} |
| 53 |
|
| 54 |
void test_5 (struct st2 *p) |
| 55 |
{ |
| 56 |
if (p->i-- > 0) |
| 57 |
test_5 (p); /* { dg-bogus "infinite recursion" } */ |
| 58 |
} |
| 59 |
|
| 60 |
/* Mixtures of heap allocation and recursion. It's not clear what we |
| 61 |
should do for such cases, but make sure we don't ICE. */ |
| 62 |
|
| 63 |
void test_6 (struct st2 *p) |
| 64 |
{ |
| 65 |
struct st2 *q = (struct st2 *) __builtin_malloc (p->i); |
| 66 |
if (!q) |
| 67 |
return; |
| 68 |
q->i = p->i; |
| 69 |
test_6 (q); |
| 70 |
__builtin_free (q); |
| 71 |
} |
| 72 |
|
| 73 |
void test_7 (struct st2 *p) |
| 74 |
{ |
| 75 |
struct st2 *q = (struct st2 *) __builtin_malloc (p->i); |
| 76 |
q->i = p->i; /* { dg-warning "dereference of possibly-NULL 'q'" } */ |
| 77 |
test_7 (q); |
| 78 |
__builtin_free (q); |
| 79 |
} |
| 80 |
|
| 81 |
void test_switch_1 (int i) |
| 82 |
{ |
| 83 |
int j; |
| 84 |
switch (i) |
| 85 |
{ |
| 86 |
case 0: |
| 87 |
j = 1066; |
| 88 |
break; |
| 89 |
case 1: |
| 90 |
j = 1776; |
| 91 |
break; |
| 92 |
default: |
| 93 |
j = 1492; |
| 94 |
break; |
| 95 |
} |
| 96 |
test_switch_1 (j); /* { dg-warning "infinite recursion" "" { xfail *-*-* } } */ |
| 97 |
} |
| 98 |
|
| 99 |
void test_switch_2 (int i) |
| 100 |
{ |
| 101 |
switch (i) |
| 102 |
{ |
| 103 |
case 0: |
| 104 |
test_switch_2 (1066); |
| 105 |
break; |
| 106 |
case 1: |
| 107 |
test_switch_2 (1776); |
| 108 |
break; |
| 109 |
default: |
| 110 |
test_switch_2 (1492); /* { dg-warning "infinite recursion" "" { xfail *-*-* } } */ |
| 111 |
break; |
| 112 |
} |
| 113 |
} |