annotate gcc/testsuite/gcc.dg/wtr-union-init-3.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for -Wtraditional warnings on union initialization.
kono
parents:
diff changeset
2 Note, gcc should omit these warnings in system header files.
kono
parents:
diff changeset
3 By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 9/11/2000. */
kono
parents:
diff changeset
4 /* { dg-do compile } */
kono
parents:
diff changeset
5 /* { dg-options "-Wtraditional" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 struct bar
kono
parents:
diff changeset
8 {
kono
parents:
diff changeset
9 int i;
kono
parents:
diff changeset
10 long j;
kono
parents:
diff changeset
11 };
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 union foo
kono
parents:
diff changeset
14 {
kono
parents:
diff changeset
15 struct bar b;
kono
parents:
diff changeset
16 int i;
kono
parents:
diff changeset
17 long l;
kono
parents:
diff changeset
18 };
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 union foo2
kono
parents:
diff changeset
21 {
kono
parents:
diff changeset
22 int i;
kono
parents:
diff changeset
23 long l;
kono
parents:
diff changeset
24 };
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 struct baz
kono
parents:
diff changeset
27 {
kono
parents:
diff changeset
28 int a;
kono
parents:
diff changeset
29 double b;
kono
parents:
diff changeset
30 union foo c;
kono
parents:
diff changeset
31 };
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 struct baz2
kono
parents:
diff changeset
34 {
kono
parents:
diff changeset
35 int a;
kono
parents:
diff changeset
36 double b;
kono
parents:
diff changeset
37 union foo2 c;
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 void
kono
parents:
diff changeset
41 testfunc ()
kono
parents:
diff changeset
42 {
kono
parents:
diff changeset
43 /* Note we only warn for nonzero initializers. Xfail on substructures. */
kono
parents:
diff changeset
44 static union foo f1 = {{0,0}}; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */
kono
parents:
diff changeset
45 static union foo f2 = {{1,1}}; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 static struct baz f3 = { 1, 2, {{0,0}} }; /* { dg-bogus "traditional C rejects initialization of unions" "initialization of unions" { xfail *-*-* } } */
kono
parents:
diff changeset
48 static struct baz f4 = { 1, 2, {{1,1}} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 static struct baz2 f5 = { 1, 2, {0} };
kono
parents:
diff changeset
51 static struct baz2 f6 = { 1, 2, {1} }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 # 54 "sys-header.h" 3
kono
parents:
diff changeset
54 /* We are in system headers now, no -Wtraditional warnings should issue. */
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 static union foo b1 = {{0,0}};
kono
parents:
diff changeset
57 static union foo b2 = {{1,1}};
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 static struct baz b3 = { 1, 2, {{0,0}} };
kono
parents:
diff changeset
60 static struct baz b4 = { 1, 2, {{1,1}} };
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 static struct baz2 b5 = { 1, 2, {0} };
kono
parents:
diff changeset
63 static struct baz2 b6 = { 1, 2, {1} };
kono
parents:
diff changeset
64 }