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
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -Wduplicate-enum
// RUN: %clang_cc1 %s -x c++ -fsyntax-only -verify -Wduplicate-enum
enum A {
A1 = 0, // expected-note {{element A1 also has value 0}}
A2 = -1,
A3, // expected-warning {{element A3 has been implicitly assigned 0 which another element has been assigned}}
A4};
enum B {
B1 = -1, // expected-note {{element B1 also has value -1}}
B2, // expected-warning {{element B2 has been implicitly assigned 0 which another element has been assigned}}
B3,
B4 = -2,
B5, // expected-warning {{element B5 has been implicitly assigned -1 which another element has been assigned}}
B6 // expected-note {{element B6 also has value 0}}
};
enum C { C1, C2 = -1, C3 }; // expected-warning{{element C1 has been implicitly assigned 0 which another element has been assigned}} \
// expected-note {{element C3 also has value 0}}
enum D {
D1,
D2,
D3, // expected-warning{{element D3 has been implicitly assigned 2 which another element has been assigned}}
D4 = D2, // no warning
D5 = 2 // expected-note {{element D5 also has value 2}}
};
enum E {
E1,
E2 = E1,
E3 = E2
};
enum F {
F1,
F2,
FCount,
FMax = FCount - 1
};
enum G {
G1,
G2,
GMax = G2,
GCount = GMax + 1
};
enum {
H1 = 0,
H2 = -1,
H3,
H4};
enum {
I1 = -1,
I2,
I3,
I4 = -2,
I5,
I6
};
enum { J1, J2 = -1, J3 };
enum {
K1,
K2,
K3,
K4 = K2,
K5 = 2
};
enum {
L1,
L2 = L1,
L3 = L2
};
enum {
M1,
M2,
MCount,
MMax = MCount - 1
};
enum {
N1,
N2,
NMax = N2,
NCount = NMax + 1
};
// PR15693
enum enum1 {
VALUE // expected-note{{previous definition is here}}
};
enum enum2 {
VALUE // expected-error{{redefinition of enumerator 'VALUE'}}
};
|