]>
Commit | Line | Data |
---|---|---|
47035bb8 ZW |
1 | /* Spurious uninitialized variable warnings. |
2 | This one inspired by java/class.c:build_utf8_ref. */ | |
3 | ||
4 | /* { dg-do compile } */ | |
5 | /* { dg-options "-O -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; | |
6de9cd9a | 37 | struct tree *field; |
47035bb8 ZW |
38 | |
39 | rv = malloc (sizeof (struct tree)); | |
40 | rv->car = 0; | |
41 | ||
6de9cd9a | 42 | APPEND(rv, field, INTEGER_T, a); /* { dg-bogus "field" "uninitialized variable warning" { xfail *-*-* } } */ |
47035bb8 ZW |
43 | APPEND(rv, field, PTR_T, b); |
44 | APPEND(rv, field, INTEGER_T, c); | |
45 | ||
46 | return rv; | |
47 | } |