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" } */
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" } */
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} };