1 /* { dg-do compile } */
2 /* { dg-options "-Wc++-compat" } */
3 enum E1 { A, B, C };
4 enum E2 { D, E, F };
5
6 enum E1 g1;
7 enum E2 g2;
8
9 void
f1()10 f1 ()
11 {
12 int a;
13 int d;
14 enum E1 e1;
15 enum E2 e2;
16 a = A;
17 a = !B;
18 d = E;
19 e1 = A;
20 e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */
21 e1 = 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
22 e1 = (enum E1) 0;
23 e1 = (enum E2) 0; /* { dg-warning "invalid in C\[+\]\[+\]" } */
24 e1 = e2; /* { dg-warning "invalid in C\[+\]\[+\]" } */
25 e1 = g1;
26 e1 = g2; /* { dg-warning "invalid in C\[+\]\[+\]" } */
27 e2 = A; /* { dg-warning "invalid in C\[+\]\[+\]" } */
28 e2 = D;
29 }
30
31 struct s { enum E1 e1 : 3; };
32
33 void
f2(struct s sv)34 f2 (struct s sv)
35 {
36 sv.e1 = A;
37 sv.e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */
38 g1 = sv.e1;
39 g2 = sv.e1; /* { dg-warning "invalid in C\[+\]\[+\]" } */
40 }
41
42 void
f3(struct s * pv)43 f3 (struct s *pv)
44 {
45 pv->e1 = A;
46 pv->e1 = D; /* { dg-warning "invalid in C\[+\]\[+\]" } */
47 g1 = pv->e1;
48 g2 = pv->e1; /* { dg-warning "invalid in C\[+\]\[+\]" } */
49 }
50