]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/uninit-4.c
a27317ebed500b1aa892f791833d8b124fc3e0b3
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / uninit-4.c
1 /* Spurious uninit variable warnings, case 4.
2 Simplified version of cppexp.c (cpp_parse_expr).
3
4 This one is really fragile, it gets it right if you take out case
5 1, or if the structure is replaced by an int, or if the structure
6 has fewer members (!) */
7
8 /* { dg-do compile } */
9 /* { dg-options "-O -Wuninitialized" } */
10
11 extern void abort (void);
12
13 struct operation {
14 short op;
15 char rprio;
16 char flags;
17 char unsignedp;
18 long value;
19 };
20
21 extern struct operation cpp_lex (void);
22
23 void
24 cpp_parse_expr (void)
25 {
26 int rprio; /* { dg-bogus "rprio" "uninitialized variable warning" { xfail *-*-* } } */
27 struct operation op;
28
29 for (;;)
30 {
31 op = cpp_lex ();
32
33 switch (op.op)
34 {
35 case 0:
36 break;
37 case 1:
38 return;
39 case 2:
40 rprio = 1;
41 break;
42 default:
43 return;
44 }
45
46 if (op.op == 0)
47 return;
48
49 if (rprio != 1)
50 abort();
51 }
52 }