[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / infinite-recursion-pr108524-2.c
blobd483d7e643c21db1b58cd36831139f9192bf814c
1 struct st1;
3 int foo (struct st1 *p);
4 int bar (struct st1 *p);
6 void test_1 (struct st1 *p)
8 test_1 (p); /* { dg-warning "infinite recursion" } */
11 void test_2_if (struct st1 *p)
13 if (foo (p))
14 test_2_if (p); /* { dg-bogus "infinite recursion" } */
17 void test_2_switch (struct st1 *p)
19 switch (foo (p))
21 case 0 ... 9:
22 test_2_switch (p); /* { dg-bogus "infinite recursion" } */
23 break;
24 default:
25 break;
29 void test_2_if_compound (struct st1 *p)
31 if ((foo (p) + bar (p)) >= 0)
32 test_2_if_compound (p); /* { dg-bogus "infinite recursion" } */
35 void test_3 (struct st1 *p)
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. */
43 struct st2
45 int i;
48 void test_4 (struct st2 *p)
50 if (p->i > 0)
51 test_4 (p); /* { dg-warning "infinite recursion" } */
54 void test_5 (struct st2 *p)
56 if (p->i-- > 0)
57 test_5 (p); /* { dg-bogus "infinite recursion" } */
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. */
63 void test_6 (struct st2 *p)
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);
73 void test_7 (struct st2 *p)
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);
81 void test_switch_1 (int i)
83 int j;
84 switch (i)
86 case 0:
87 j = 1066;
88 break;
89 case 1:
90 j = 1776;
91 break;
92 default:
93 j = 1492;
94 break;
96 test_switch_1 (j); /* { dg-warning "infinite recursion" "" { xfail *-*-* } } */
99 void test_switch_2 (int i)
101 switch (i)
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;