Alex Lorenz | f127821 | 2017-04-11 15:01:53 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-objc-root-class -Wno-incomplete-implementation -triple x86_64-apple-macosx10.10.0 -verify %s |
| 2 | |
| 3 | // rdar://20626062 |
| 4 | |
| 5 | struct S { |
| 6 | int throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}} |
| 7 | }; |
| 8 | |
| 9 | @interface class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 10 | @end |
| 11 | |
| 12 | @interface Bar: class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 13 | @end |
| 14 | |
| 15 | @protocol P // ok |
| 16 | @end |
| 17 | |
| 18 | @protocol new // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}} |
| 19 | @end |
| 20 | |
Alex Lorenz | b111da1 | 2018-08-17 22:18:08 +0000 | [diff] [blame] | 21 | @protocol P2; |
| 22 | @protocol delete // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}} |
| 23 | @end |
Alex Lorenz | f127821 | 2017-04-11 15:01:53 +0000 | [diff] [blame] | 24 | |
| 25 | @class Foo, try; // expected-error {{expected identifier; 'try' is a keyword in Objective-C++}} |
| 26 | |
| 27 | @interface Foo |
| 28 | |
| 29 | @property (readwrite, nonatomic) int a, b, throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}} |
| 30 | |
| 31 | -foo:(int)class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 32 | +foo:(int)constexpr; // expected-error {{expected identifier; 'constexpr' is a keyword in Objective-C++}} |
| 33 | |
| 34 | @end |
| 35 | |
| 36 | @interface Foo () <P, new> // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}} |
| 37 | @end |
| 38 | |
| 39 | @implementation Foo |
| 40 | |
| 41 | @synthesize a = _a; // ok |
| 42 | @synthesize b = virtual; // expected-error {{expected identifier; 'virtual' is a keyword in Objective-C++}} |
| 43 | |
| 44 | @dynamic throw; // expected-error {{expected identifier; 'throw' is a keyword in Objective-C++}} |
| 45 | |
| 46 | -foo:(int)class { // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 47 | } |
| 48 | |
| 49 | @end |
| 50 | |
| 51 | @implementation class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 52 | @end |
| 53 | |
| 54 | @implementation Bar: class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 55 | @end |
| 56 | |
| 57 | @compatibility_alias C Foo; // ok |
| 58 | @compatibility_alias const_cast Bar; // expected-error {{expected identifier; 'const_cast' is a keyword in Objective-C++}} |
| 59 | @compatibility_alias C2 class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}} |
| 60 | |
| 61 | void func() { |
| 62 | (void)@protocol(P); // ok |
| 63 | (void)@protocol(delete); // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}} |
| 64 | } |