Move the c-torture/noncompile tests to either gcc.dg/cpp or a new
[official-gcc.git] / gcc / testsuite / gcc.dg / uninit-6.c
blob2c428df79b602febf8cc1f52cd841f7299274c5b
1 /* Spurious uninitialized variable warnings.
2 This one inspired by java/class.c:build_utf8_ref. */
4 /* { dg-do compile } */
5 /* { dg-options "-O -Wuninitialized" } */
7 #include <stddef.h>
9 struct tree
11 struct tree *car;
12 struct tree *cdr;
13 int type, data;
16 extern void *malloc(size_t);
18 #define INTEGER_T 1
19 #define PTR_T 2
21 #define APPEND(TREE, LAST, TYPE, VALUE) \
22 do { \
23 struct tree *tmp = malloc (sizeof (struct tree)); \
24 tmp->car = 0; tmp->cdr = 0; tmp->type = TYPE; \
25 tmp->data = VALUE; \
26 if (TREE->car) \
27 LAST->cdr = tmp; \
28 else \
29 TREE->car = tmp; \
30 LAST = tmp; \
31 } while(0)
33 struct tree *
34 make_something(int a, int b, int c)
36 struct tree *rv;
37 struct tree *field; /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */
39 rv = malloc (sizeof (struct tree));
40 rv->car = 0;
42 APPEND(rv, field, INTEGER_T, a);
43 APPEND(rv, field, PTR_T, b);
44 APPEND(rv, field, INTEGER_T, c);
46 return rv;