OSDN Git Service

* gcc.dg/weak/typeof-2.c: Needs aliases as well as weak.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / wtr-union-init-3.c
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" } */
6
7 struct bar
8 {
9   int i;
10   long j;
11 };
12
13 union foo
14 {
15   struct bar b;
16   int i;
17   long l;
18 };
19
20 union foo2
21 {
22   int i;
23   long l;
24 };
25
26 struct baz
27 {
28   int a;
29   double b;
30   union foo c;
31 };
32
33 struct baz2
34 {
35   int a;
36   double b;
37   union foo2 c;
38 };
39
40 void
41 testfunc ()
42 {
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" } */
46
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" } */
49
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" } */
52
53 # 54 "sys-header.h" 3
54 /* We are in system headers now, no -Wtraditional warnings should issue.  */
55
56   static union foo b1 = {{0,0}};
57   static union foo b2 = {{1,1}};
58
59   static struct baz b3 = { 1, 2, {{0,0}} };
60   static struct baz b4 = { 1, 2, {{1,1}} };
61
62   static struct baz2 b5 = { 1, 2, {0} };
63   static struct baz2 b6 = { 1, 2, {1} };
64 }