2007-07-24 01:05:23 +08:00
|
|
|
// RUN: clang -parse-ast-check %s
|
|
|
|
|
|
|
|
void f (int z) {
|
|
|
|
while (z) {
|
2007-08-24 02:29:20 +08:00
|
|
|
default: z--; // expected-error {{statement not in switch}}
|
2007-07-24 01:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-23 13:46:52 +08:00
|
|
|
void foo(int X) {
|
|
|
|
switch (X) {
|
2007-08-24 02:29:20 +08:00
|
|
|
case 42: ; // expected-error {{previous case value}}
|
|
|
|
case 5000000000LL: // expected-warning {{overflow}}
|
|
|
|
case 42: // expected-error {{duplicate case value}}
|
2007-08-23 13:46:52 +08:00
|
|
|
;
|
2007-08-24 01:48:14 +08:00
|
|
|
|
2007-08-24 02:29:20 +08:00
|
|
|
case 100 ... 99: ; // expected-warning {{empty case range}}
|
|
|
|
|
|
|
|
case 43: ; // expected-error {{previous case value}}
|
|
|
|
case 43 ... 45: ; // expected-error {{duplicate case value}}
|
|
|
|
|
|
|
|
case 100 ... 20000:; // expected-error {{previous case value}}
|
|
|
|
case 15000 ... 40000000:; // expected-error {{duplicate case value}}
|
2007-08-23 13:46:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-23 22:29:07 +08:00
|
|
|
void test3(void) {
|
2007-08-24 02:29:20 +08:00
|
|
|
// empty switch;
|
2007-08-23 22:29:07 +08:00
|
|
|
switch (0);
|
|
|
|
}
|
|
|
|
|