xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/gcc.dg/uninit-9.c (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1*c87b03e5Sespie /* Spurious uninitialized variable warnings.  Slight variant on the
2*c87b03e5Sespie    documented case, inspired by reg-stack.c:record_asm_reg_life.  */
3*c87b03e5Sespie 
4*c87b03e5Sespie /* { dg-do compile } */
5*c87b03e5Sespie /* { dg-options "-O -Wuninitialized" } */
6*c87b03e5Sespie 
7*c87b03e5Sespie struct foo
8*c87b03e5Sespie {
9*c87b03e5Sespie     int type;
10*c87b03e5Sespie     struct foo *car;
11*c87b03e5Sespie     struct foo *cdr;
12*c87b03e5Sespie     char *data;
13*c87b03e5Sespie     int data2;
14*c87b03e5Sespie };
15*c87b03e5Sespie 
16*c87b03e5Sespie extern void use(struct foo *);
17*c87b03e5Sespie 
18*c87b03e5Sespie #define CLOBBER 6
19*c87b03e5Sespie #define PARALLEL 3
20*c87b03e5Sespie 
21*c87b03e5Sespie void
func(struct foo * list,int count)22*c87b03e5Sespie func(struct foo *list, int count)
23*c87b03e5Sespie {
24*c87b03e5Sespie     int n_clobbers = 0;
25*c87b03e5Sespie     int i;
26*c87b03e5Sespie     struct foo **clob_list;   /* { dg-bogus "clob_list" "uninitialized variable warning" { xfail *-*-* } } */
27*c87b03e5Sespie 
28*c87b03e5Sespie     if(list[0].type == PARALLEL)
29*c87b03e5Sespie     {
30*c87b03e5Sespie 	clob_list = __builtin_alloca(count * sizeof(struct foo *));
31*c87b03e5Sespie 
32*c87b03e5Sespie 	for(i = 1; i < count; i++)
33*c87b03e5Sespie 	{
34*c87b03e5Sespie 	    if(list[i].type == CLOBBER)
35*c87b03e5Sespie 		clob_list[n_clobbers++] = &list[i];
36*c87b03e5Sespie 	}
37*c87b03e5Sespie     }
38*c87b03e5Sespie 
39*c87b03e5Sespie     for(i = 0; i < n_clobbers; i++)
40*c87b03e5Sespie 	use(clob_list[i]);
41*c87b03e5Sespie }
42