1 /* Positive test for uninitialized variables. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wuninitialized" } */
4
5 int sink;
6
f1(int parm)7 void f1(int parm) /* { dg-bogus "uninitialized" "parameter" } */
8 {
9 sink = parm; /* { dg-bogus "uninitialized" "parameter" } */
10 }
11
f2(void)12 void f2(void)
13 {
14 int x;
15 sink = x; /* { dg-warning "is used" "unconditional" } */
16 }
17
f3(int p)18 void f3(int p)
19 {
20 int x; /* { dg-warning "may be used" "conditional" { xfail *-*-* } } */
21 if (p)
22 x = p;
23 sink = x;
24 }
25
f4(int p)26 void f4(int p)
27 {
28 int x; /* { dg-bogus "uninitialized" "easy if" } */
29 if (p)
30 x = 1;
31 else
32 x = 2;
33 sink = x;
34 }
35
f5(void)36 void f5(void)
37 {
38 int x, i; /* { dg-bogus "uninitialized" "easy loop" } */
39 for (i = 0; i < 10; ++i)
40 x = 1;
41 sink = x;
42 }
43