xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/gcc.dg/uninit-5.c (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 /* Spurious uninitialized-variable warnings.
2    These cases are documented as not working in the gcc manual. */
3 
4 /* { dg-do compile } */
5 /* { dg-options "-O -Wuninitialized" } */
6 
7 extern void use(int);
8 extern void foo(void);
9 
10 void
func1(int cond)11 func1(int cond)
12 {
13     int x;  /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */
14 
15     if(cond)
16 	x = 1;
17 
18     foo();
19 
20     if(cond)
21 	use(x);
22 }
23 
24 void
func2(int cond)25 func2 (int cond)
26 {
27     int x;  /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */
28     int flag = 0;
29 
30     if(cond)
31     {
32 	x = 1;
33 	flag = 1;
34     }
35 
36     foo();
37 
38     if(flag)
39 	use(x);
40 }
41