Douglas Gregor | 4186ff4 | 2010-05-20 23:20:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | // <rdar://problem/7971948> |
| 4 | struct A {}; |
| 5 | struct B { |
Douglas Gregor | 662a482 | 2010-12-23 22:56:40 +0000 | [diff] [blame] | 6 | void foo(int b) { |
Douglas Gregor | 4186ff4 | 2010-05-20 23:20:59 +0000 | [diff] [blame] | 7 | switch (a) { // expected-error{{use of undeclared identifier 'a'}} |
| 8 | default: |
| 9 | return; |
| 10 | } |
Douglas Gregor | 662a482 | 2010-12-23 22:56:40 +0000 | [diff] [blame] | 11 | |
| 12 | switch (b) { |
| 13 | case 17 // expected-error{{expected ':' after 'case'}} |
| 14 | break; |
| 15 | |
| 16 | default // expected-error{{expected ':' after 'default'}} |
| 17 | return; |
| 18 | } |
Douglas Gregor | 4186ff4 | 2010-05-20 23:20:59 +0000 | [diff] [blame] | 19 | } |
John McCall | f6a3ab0 | 2011-01-22 09:28:32 +0000 | [diff] [blame^] | 20 | |
| 21 | void test2() { |
| 22 | enum X { Xa, Xb } x; |
| 23 | |
| 24 | switch (x) { // expected-warning {{enumeration value 'Xb' not handled in switch}} |
| 25 | case Xa; // expected-error {{expected ':' after 'case'}} |
| 26 | break; |
| 27 | } |
| 28 | |
| 29 | switch (x) { |
| 30 | default; // expected-error {{expected ':' after 'default'}} |
| 31 | break; |
| 32 | } |
| 33 | } |
Douglas Gregor | 4186ff4 | 2010-05-20 23:20:59 +0000 | [diff] [blame] | 34 | }; |