1 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple
2 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple %ms_abi_triple -DMSABI
4 enum Foo
{ FooA
, FooB
, FooC
};
5 enum Bar
{ BarD
, BarE
, BarF
};
6 enum { AnonAA
= 42, AnonAB
= 43 };
7 enum { AnonBA
= 44, AnonBB
= 45 };
8 enum { Anon1
, Anon2
, Anon3
};
9 typedef enum { TD1
, TD2
} TD
;
12 enum Foo
{F1
, F2
, F3
};
13 enum Baz
{B1
, B2
, B3
};
17 enum Baz
{B1
, B2
, B3
};
23 typedef name1::Foo oneFoo
;
24 typedef name1::Foo twoFoo
;
39 while (a
== name1::F1
);
40 while (z
== name1::B2
);
44 while (B1
== name1::B2
);
45 while (B2
== name2::B1
);
47 while (x
== AnonAA
); // expected-warning {{comparison of constant 'AnonAA' (42) with expression of type 'Foo' is always false}}
48 while (AnonBB
== y
); // expected-warning {{comparison of constant 'AnonBB' (45) with expression of type 'Bar' is always false}}
50 while (AnonAA
== AnonAB
);
51 while (AnonAB
== AnonBA
);
52 while (AnonBB
== AnonAA
);
56 while ((a
) == name1::F1
);
57 while (z
== (name1::B2
));
61 while ((B1
) == (name1::B2
));
62 while ((B2
) == (name2::B1
));
64 while (((x
)) == FooA
);
65 while ((y
) == (BarD
));
66 while ((a
) == (name1::F1
));
67 while (z
== (name1::B2
));
68 while ((a
) == ((((b
)))));
70 while ((b
) == (((c
))));
71 while ((((((B1
))))) == (((name1::B2
))));
72 while (B2
== ((((((name2::B1
)))))));
76 while (td
== AnonAA
); // expected-warning {{comparison of constant 'AnonAA' (42) with expression of type 'TD' is always false}}
79 while (B1
== B2
); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
80 while (name1::B2
== name2::B3
); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
81 while (z
== name2::B2
); // expected-warning {{comparison of different enumeration types ('Baz' and 'name2::Baz')}}
83 while (((((B1
)))) == B2
); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
84 while (name1::B2
== (name2::B3
)); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
85 while (z
== ((((name2::B2
))))); // expected-warning {{comparison of different enumeration types ('Baz' and 'name2::Baz')}}
87 while ((((B1
))) == (((B2
)))); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
88 while ((name1::B2
) == (((name2::B3
)))); // expected-warning {{comparison of different enumeration types ('name1::Baz' and 'name2::Baz')}}
89 while ((((z
))) == (name2::B2
)); // expected-warning {{comparison of different enumeration types ('Baz' and 'name2::Baz')}}
91 while (x
== a
); // expected-warning {{comparison of different enumeration types ('Foo' and 'name1::Foo')}}
92 while (x
== b
); // expected-warning {{comparison of different enumeration types ('Foo' and 'oneFoo' (aka 'name1::Foo'))}}
93 while (x
== c
); // expected-warning {{comparison of different enumeration types ('Foo' and 'twoFoo' (aka 'name1::Foo'))}}
95 while (x
== y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
96 while (x
!= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
97 while (x
>= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
98 while (x
<= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
99 while (x
> y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
100 while (x
< y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
102 while (FooB
== y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
103 while (FooB
!= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
104 while (FooB
>= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
105 while (FooB
<= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
106 while (FooB
> y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
107 while (FooB
< y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
109 while (FooB
== BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
110 while (FooB
!= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
111 while (FooB
>= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
112 while (FooB
<= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
113 while (FooB
> BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
114 while (FooB
< BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
116 while (x
== BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
117 while (x
!= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
118 while (x
>= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
119 while (x
<= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
120 while (x
> BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
121 while (x
< BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
123 while (getFoo() == y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
124 while (getFoo() != y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
125 while (getFoo() >= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
126 while (getFoo() <= y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
127 while (getFoo() > y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
128 while (getFoo() < y
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
130 while (getFoo() == BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
131 while (getFoo() != BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
132 while (getFoo() >= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
133 while (getFoo() <= BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
134 while (getFoo() > BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
135 while (getFoo() < BarD
); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
137 while (getFoo() == getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
138 while (getFoo() != getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
139 while (getFoo() >= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
140 while (getFoo() <= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
141 while (getFoo() > getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
142 while (getFoo() < getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
144 while (FooB
== getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
145 while (FooB
!= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
146 while (FooB
>= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
147 while (FooB
<= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
148 while (FooB
> getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
149 while (FooB
< getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
151 while (x
== getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
152 while (x
!= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
153 while (x
>= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
154 while (x
<= getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
155 while (x
> getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
156 while (x
< getBar()); // expected-warning {{comparison of different enumeration types ('Foo' and 'Bar')}}
160 while (y
== x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
161 while (y
!= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
162 while (y
>= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
163 while (y
<= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
164 while (y
> x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
165 while (y
< x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
167 while (y
== FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
168 while (y
!= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
169 while (y
>= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
170 while (y
<= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
171 while (y
> FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
172 while (y
< FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
174 while (BarD
== FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
175 while (BarD
!= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
176 while (BarD
>= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
177 while (BarD
<= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
178 while (BarD
> FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
179 while (BarD
<FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
181 while (BarD
== x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
182 while (BarD
!= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
183 while (BarD
>= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
184 while (BarD
<= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
185 while (BarD
< x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
186 while (BarD
> x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
188 while (y
== getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
189 while (y
!= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
190 while (y
>= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
191 while (y
<= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
192 while (y
> getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
193 while (y
< getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
195 while (BarD
== getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
196 while (BarD
!= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
197 while (BarD
>= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
198 while (BarD
<= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
199 while (BarD
> getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
200 while (BarD
< getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
202 while (getBar() == getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
203 while (getBar() != getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
204 while (getBar() >= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
205 while (getBar() <= getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
206 while (getBar() > getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
207 while (getBar() < getFoo()); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
209 while (getBar() == FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
210 while (getBar() != FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
211 while (getBar() >= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
212 while (getBar() <= FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
213 while (getBar() > FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
214 while (getBar() < FooB
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
216 while (getBar() == x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
217 while (getBar() != x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
218 while (getBar() >= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
219 while (getBar() <= x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
220 while (getBar() > x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
221 while (getBar() < x
); // expected-warning {{comparison of different enumeration types ('Bar' and 'Foo')}}
223 while (td
== FooA
); // expected-warning {{comparison of different enumeration types ('TD' and 'Foo')}}
224 while (td
== BarD
); // expected-warning {{comparison of different enumeration types ('TD' and 'Bar')}}
225 while (name1::F1
== td
); // expected-warning {{comparison of different enumeration types ('name1::Foo' and 'TD')}}
226 while (name2::B1
== td
); // expected-warning {{comparison of different enumeration types ('name2::Baz' and 'TD')}}
227 while (td
== a
); // expected-warning {{comparison of different enumeration types ('TD' and 'name1::Foo')}}
228 while (td
== b
); // expected-warning {{comparison of different enumeration types ('TD' and 'oneFoo' (aka 'name1::Foo'))}}
229 while (td
== c
); // expected-warning {{comparison of different enumeration types ('TD' and 'twoFoo' (aka 'name1::Foo'))}}
230 while (td
== x
); // expected-warning {{comparison of different enumeration types ('TD' and 'Foo')}}
231 while (td
== y
); // expected-warning {{comparison of different enumeration types ('TD' and 'Bar')}}
232 while (td
== z
); // expected-warning {{comparison of different enumeration types ('TD' and 'Baz')}}
234 while (a
== TD1
); // expected-warning {{comparison of different enumeration types ('name1::Foo' and 'TD')}}
235 while (b
== TD2
); // expected-warning {{comparison of different enumeration types ('oneFoo' (aka 'name1::Foo') and 'TD')}}
236 while (c
== TD1
); // expected-warning {{comparison of different enumeration types ('twoFoo' (aka 'name1::Foo') and 'TD')}}
237 while (x
== TD2
); // expected-warning {{comparison of different enumeration types ('Foo' and 'TD')}}
238 while (y
== TD1
); // expected-warning {{comparison of different enumeration types ('Bar' and 'TD')}}
239 while (z
== TD2
); // expected-warning {{comparison of different enumeration types ('Baz' and 'TD')}}
242 case name1::F1
: break;
243 case name1::F3
: break;
244 case name2::B2
: break; // expected-warning {{comparison of different enumeration types in switch statement ('name1::Foo' and 'name2::Baz')}}
250 case BarD
: break; // expected-warning {{comparison of different enumeration types in switch statement ('Foo' and 'Bar')}}
256 case FooA
: break; // expected-warning {{comparison of different enumeration types in switch statement ('Bar' and 'Foo')}}
260 case AnonAA
: break; // expected-warning {{case value not in enumerated type 'Foo'}}
268 case FooB
: break; // expected-warning {{comparison of different enumeration types in switch statement ('TD' and 'Foo')}}
269 case BarF
: break; // expected-warning {{comparison of different enumeration types in switch statement ('TD' and 'Bar')}}
270 // expected-warning@-1 {{case value not in enumerated type 'TD'}}
271 case AnonAA
: break; // expected-warning {{case value not in enumerated type 'TD'}}
280 case TD1
: break; // expected-warning {{comparison of different enumeration types in switch statement ('name1::Foo' and 'TD')}}
281 case TD2
: break; // expected-warning {{comparison of different enumeration types in switch statement ('name1::Foo' and 'TD')}}
282 case name1::F3
: break;