Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fsyntax-only %s |
Chris Lattner | 8129edb | 2009-04-12 22:23:27 +0000 | [diff] [blame] | 2 | |
| 3 | int x(*g); // expected-error {{use of undeclared identifier 'g'}} |
Chris Lattner | 4664649 | 2009-12-07 01:36:53 +0000 | [diff] [blame] | 4 | |
Chris Lattner | a69d0ed | 2009-12-10 02:02:58 +0000 | [diff] [blame] | 5 | struct Type { |
| 6 | int Type; |
| 7 | }; |
Chris Lattner | a1efc8c | 2009-12-10 01:59:24 +0000 | [diff] [blame] | 8 | |
Chris Lattner | 4664649 | 2009-12-07 01:36:53 +0000 | [diff] [blame] | 9 | |
| 10 | // PR4451 - We should recover well from the typo of '::' as ':' in a2. |
| 11 | namespace y { |
Chris Lattner | 932dff7 | 2009-12-10 02:08:07 +0000 | [diff] [blame] | 12 | struct a { }; |
| 13 | typedef int b; |
Chris Lattner | 4664649 | 2009-12-07 01:36:53 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | y::a a1; |
| 17 | y:a a2; // expected-error {{unexpected ':' in nested name specifier}} |
| 18 | y::a a3 = a2; |
| 19 | |
| 20 | // Some valid colons: |
| 21 | void foo() { |
| 22 | y: // label |
| 23 | y::a s; |
| 24 | |
| 25 | int a = 4; |
| 26 | a = a ? a : a+1; |
| 27 | } |
| 28 | |
| 29 | struct b : y::a {}; |
| 30 | |
| 31 | template <typename T> |
| 32 | class someclass { |
| 33 | |
| 34 | int bar() { |
| 35 | T *P; |
| 36 | return 1 ? P->x : P->y; |
| 37 | } |
| 38 | }; |
Chris Lattner | a1efc8c | 2009-12-10 01:59:24 +0000 | [diff] [blame] | 39 | |
| 40 | enum { fooenum = 1 }; |
| 41 | |
| 42 | struct a { |
| 43 | int Type : fooenum; |
| 44 | }; |
| 45 | |
Chris Lattner | a69d0ed | 2009-12-10 02:02:58 +0000 | [diff] [blame] | 46 | void test(struct Type *P) { |
| 47 | int Type; |
| 48 | Type = 1 ? P->Type : Type; |
Chris Lattner | 932dff7 | 2009-12-10 02:08:07 +0000 | [diff] [blame] | 49 | |
| 50 | Type = (y:b) 4; // expected-error {{unexpected ':' in nested name specifier}} |
| 51 | Type = 1 ? ( |
| 52 | (y:b) // expected-error {{unexpected ':' in nested name specifier}} |
| 53 | 4) : 5; |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 54 | } |
Chris Lattner | ae50d50 | 2010-02-02 00:43:15 +0000 | [diff] [blame] | 55 | |
| 56 | struct test4 { |
| 57 | int x // expected-error {{expected ';' at end of declaration list}} |
| 58 | int y; |
| 59 | int z // expected-error {{expected ';' at end of declaration list}} |
| 60 | }; |
John McCall | 2e0a715 | 2010-03-01 18:20:46 +0000 | [diff] [blame] | 61 | |
| 62 | // PR5825 |
| 63 | struct test5 {}; |
| 64 | ::new(static_cast<void*>(0)) test5; // expected-error {{expected unqualified-id}} |
Chris Lattner | 5c5db55 | 2010-04-05 18:18:31 +0000 | [diff] [blame] | 65 | |
| 66 | |
| 67 | // PR6782 |
| 68 | template<class T> |
| 69 | class Class1; |
| 70 | |
| 71 | class Class2 { |
| 72 | } // no ; |
| 73 | |
| 74 | typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}} |