1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* { dg-do compile } */
/* { dg-options "-Wc++-compat" } */
enum E1 { A, B, C };
enum E2 { D, E, F };
enum E1 v1a = A;
enum E1 v1b = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */
enum E1 v1c = 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
enum E1 v1d = (enum E1) 0;
enum E1 v1e = (enum E2) 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
enum E2 v2a;
enum E1 a1[] =
{
A,
D, /* { dg-warning "invalid in C\[+\]\[+\]" } */
0, /* { dg-warning "invalid in C\[+\]\[+\]" } */
(enum E1) 0,
(enum E2) 0, /* { dg-warning "invalid in C\[+\]\[+\]" } */
A
};
struct s1
{
enum E1 e1;
};
struct s1 a2[] =
{
{ A },
{ D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ (enum E1) 0 },
{ (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ A }
};
struct s1 a3[] =
{
[ 5 ] = { .e1 = A },
[ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 2 ] = { .e1 = (enum E1) 0 },
[ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 0 ] = { .e1 = A }
};
struct s2
{
enum E1 e1 : 3;
};
struct s2 a4[] =
{
{ A },
{ D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ (enum E1) 0 },
{ (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ A }
};
struct s2 a5[] =
{
[ 5 ] = { .e1 = A },
[ 4 ] = { .e1 = D }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 3 ] = { .e1 = 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 2 ] = { .e1 = (enum E1) 0 },
[ 1 ] = { .e1 = (enum E2) 0 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
[ 0 ] = { .e1 = A }
};
void
f(enum E1 e1, enum E2 e2, struct s1 vs1, struct s1 *vp1)
{
enum E1 va1[] = {
e1,
e2, /* { dg-warning "invalid in C\[+\]\[+\]" } */
v1a,
v2a, /* { dg-warning "invalid in C\[+\]\[+\]" } */
vs1.e1,
vp1->e1,
e1 ? e1 : e1,
(0, e1)
};
struct s1 va2[] = {
{ e1 },
{ e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ v1a },
{ v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ vs1.e1 },
{ vp1->e1 },
{ e1 ? e1 : e1 },
{ (0, e1) }
};
struct s2 va3[] = {
{ e1 },
{ e2 }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ v1a },
{ v2a }, /* { dg-warning "invalid in C\[+\]\[+\]" } */
{ vs1.e1 },
{ vp1->e1 },
{ e1 ? e1 : e1 },
{ (0, e1) }
};
}
/* Match all extra informative notes. */
/* { dg-message "near initialization for" "expected" { target *-*-* } 0 } */
|