* gcc.dg/const-elim-1.c: Remove xfail for xtensa-*-*.
[official-gcc.git] / gcc / testsuite / gcc.dg / wtr-union-init-3.c
blob407554a9c194433fbc4762016b9fa256c4219bb1
1 /* Test for -Wtraditional warnings on union initialization.
2 Note, gcc should omit these warnings in system header files.
3 By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 9/11/2000. */
4 /* { dg-do compile } */
5 /* { dg-options "-Wtraditional" } */
7 struct bar
9 int i;
10 long j;
13 union foo
15 struct bar b;
16 int i;
17 long l;
20 union foo2
22 int i;
23 long l;
26 struct baz
28 int a;
29 double b;
30 union foo c;
33 struct baz2
35 int a;
36 double b;
37 union foo2 c;
40 void
41 testfunc ()
43 /* Note we only warn for nonzero initializers. Xfail on substructures. */
44 static union foo f1 = {{0,0}}; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */
45 static union foo f2 = {{1,1}}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
47 static struct baz f3 = { 1, 2, {{0,0}} }; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */
48 static struct baz f4 = { 1, 2, {{1,1}} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
50 static struct baz2 f5 = { 1, 2, {0} };
51 static struct baz2 f6 = { 1, 2, {1} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
53 # 54 "sys-header.h" 3
54 /* We are in system headers now, no -Wtraditional warnings should issue. */
56 static union foo b1 = {{0,0}};
57 static union foo b2 = {{1,1}};
59 static struct baz b3 = { 1, 2, {{0,0}} };
60 static struct baz b4 = { 1, 2, {{1,1}} };
62 static struct baz2 b5 = { 1, 2, {0} };
63 static struct baz2 b6 = { 1, 2, {1} };