Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / uninit-6.c
blob009e124fccf8972f22ba720224f7400f22f85c89
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;
39 rv = malloc (sizeof (struct tree));
40 rv->car = 0;
42 APPEND(rv, field, INTEGER_T, a); /* { dg-bogus "field" "uninitialized variable warning" } */
43 APPEND(rv, field, PTR_T, b);
44 APPEND(rv, field, INTEGER_T, c);
46 return rv;