2007-10-11 04:18:28 +04:00
|
|
|
// RUN: clang -fsyntax-only -verify %s
|
2007-07-23 21:05:23 +04:00
|
|
|
|
|
|
|
void f (int z) {
|
|
|
|
while (z) {
|
2007-08-23 22:29:20 +04:00
|
|
|
default: z--; // expected-error {{statement not in switch}}
|
2007-07-23 21:05:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-23 09:46:52 +04:00
|
|
|
void foo(int X) {
|
|
|
|
switch (X) {
|
2007-08-23 22:29:20 +04:00
|
|
|
case 42: ; // expected-error {{previous case value}}
|
|
|
|
case 5000000000LL: // expected-warning {{overflow}}
|
|
|
|
case 42: // expected-error {{duplicate case value}}
|
2007-08-23 09:46:52 +04:00
|
|
|
;
|
2007-08-23 21:48:14 +04:00
|
|
|
|
2007-08-23 22:29:20 +04: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 09:46:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-23 18:29:07 +04:00
|
|
|
void test3(void) {
|
2007-08-23 22:29:20 +04:00
|
|
|
// empty switch;
|
2007-08-23 18:29:07 +04:00
|
|
|
switch (0);
|
|
|
|
}
|
|
|
|
|