2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / Wcxx-compat-6.c
blobeee6768f0b69c15f05c142b411b2087115ed85e4
1 /* { dg-do compile } */
2 /* { dg-options "-Wc++-compat" } */
3 enum E1 { A, B, C };
4 enum E2 { D, E, F };
6 enum E1 v1a = A;
7 enum E1 v1b = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */
8 enum E1 v1c = 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
9 enum E1 v1d = (enum E1) 0;
10 enum E1 v1e = (enum E2) 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
12 enum E2 v2a;
14 enum E1 a1[] =
17 D, /* { dg-warning "invalid in C\[+\]\[+\]" } */
18 0, /* { dg-warning "invalid in C\[+\]\[+\]" } */
19 (enum E1) 0,
20 (enum E2) 0, /* { dg-warning "invalid in C\[+\]\[+\]" } */
24 struct s1
26 enum E1 e1;
29 struct s1 a2[] =
31 { A },
32 { D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
33 { 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
34 { (enum E1) 0 },
35 { (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
36 { A }
39 struct s1 a3[] =
41 [ 5 ] = { .e1 = A },
42 [ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
43 [ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
44 [ 2 ] = { .e1 = (enum E1) 0 },
45 [ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
46 [ 0 ] = { .e1 = A }
49 struct s2
51 enum E1 e1 : 3;
54 struct s2 a4[] =
56 { A },
57 { D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
58 { 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
59 { (enum E1) 0 },
60 { (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
61 { A }
64 struct s2 a5[] =
66 [ 5 ] = { .e1 = A },
67 [ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
68 [ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
69 [ 2 ] = { .e1 = (enum E1) 0 },
70 [ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
71 [ 0 ] = { .e1 = A }
74 void
75 f(enum E1 e1, enum E2 e2, struct s1 vs1, struct s1 *vp1)
77 enum E1 va1[] = {
78 e1,
79 e2, /* { dg-warning "invalid in C\[+\]\[+\]" } */
80 v1a,
81 v2a, /* { dg-warning "invalid in C\[+\]\[+\]" } */
82 vs1.e1,
83 vp1->e1,
84 e1 ? e1 : e1,
85 (0, e1)
88 struct s1 va2[] = {
89 { e1 },
90 { e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
91 { v1a },
92 { v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
93 { vs1.e1 },
94 { vp1->e1 },
95 { e1 ? e1 : e1 },
96 { (0, e1) }
99 struct s2 va3[] = {
100 { e1 },
101 { e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
102 { v1a },
103 { v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
104 { vs1.e1 },
105 { vp1->e1 },
106 { e1 ? e1 : e1 },
107 { (0, e1) }
111 /* Match all extra informative notes. */
112 /* { dg-message "near initialization for" "expected" { target *-*-* } 0 } */