OSDN Git Service

* c-decl.c (grokfield): Allow typedefs for anonymous structs and
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / uninit-6-O0.c
1 /* Spurious uninitialized variable warnings.
2    This one inspired by java/class.c:build_utf8_ref.  */
3
4 /* { dg-do compile } */
5 /* { dg-options "-Wuninitialized" } */
6
7 #include <stddef.h>
8
9 struct tree
10 {
11     struct tree *car;
12     struct tree *cdr;
13     int type, data;
14 };
15
16 extern void *malloc(size_t);
17
18 #define INTEGER_T 1
19 #define PTR_T     2
20
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)
32  
33 struct tree *
34 make_something(int a, int b, int c)
35 {
36     struct tree *rv;
37     struct tree *field;
38
39     rv = malloc (sizeof (struct tree));
40     rv->car = 0;
41
42     APPEND(rv, field, INTEGER_T, a);  /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */
43     APPEND(rv, field, PTR_T, b);
44     APPEND(rv, field, INTEGER_T, c);
45
46     return rv;
47 }