PR middle-end/27945
[official-gcc.git] / gcc / testsuite / gcc.dg / uninit-11.c
blob5251f0a2a701f851a8f0725220b3e76e8f1824a6
1 /* Positive test for uninitialized variables. */
2 /* { dg-do compile } */
3 /* { dg-options "-O -Wuninitialized" } */
5 int sink;
7 void f1(int parm) /* { dg-bogus "uninitialized" "parameter" } */
9 sink = parm; /* { dg-bogus "uninitialized" "parameter" } */
12 void f2(void)
14 int x;
15 sink = x; /* { dg-warning "is used" "unconditional" } */
18 void f3(int p)
20 int x; /* { dg-warning "may be used" "conditional" } */
21 if (p)
22 x = p;
23 sink = x;
26 void f4(int p)
28 int x; /* { dg-bogus "uninitialized" "easy if" } */
29 if (p)
30 x = 1;
31 else
32 x = 2;
33 sink = x;
36 void f5(void)
38 int x, i; /* { dg-bogus "uninitialized" "easy loop" } */
39 for (i = 0; i < 10; ++i)
40 x = 1;
41 sink = x;