You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used
as identifiers in Objective-C++
This commit improves the 'expected identifier' errors that are presented when a
C++ keyword is used as an identifier in Objective-C++ by mentioning that this is
a C++ keyword in the diagnostic message. It also improves the error recovery:
the parser will now treat the C++ keywords as identifiers to prevent unrelated
parsing errors.
rdar://20626062
Differential Revision: https://reviews.llvm.org/D26503
llvm-svn: 299950
intthrow; // 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
+
@protocolP// ok
16
+
@end
17
+
18
+
@protocolnew// expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
19
+
@end
20
+
21
+
@protocol P2, delete; // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
22
+
23
+
@class Foo, try; // expected-error {{expected identifier; 'try' is a keyword in Objective-C++}}
24
+
25
+
@interfaceFoo
26
+
27
+
@property (readwrite, nonatomic) int a, b, throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}}
28
+
29
+
-foo:(int)class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
30
+
+foo:(int)constexpr; // expected-error {{expected identifier; 'constexpr' is a keyword in Objective-C++}}
31
+
32
+
@end
33
+
34
+
@interface Foo () <P, new> // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
35
+
@end
36
+
37
+
@implementation Foo
38
+
39
+
@synthesize a = _a; // ok
40
+
@synthesize b = virtual; // expected-error {{expected identifier; 'virtual' is a keyword in Objective-C++}}
41
+
42
+
@dynamic throw; // expected-error {{expected identifier; 'throw' is a keyword in Objective-C++}}
43
+
44
+
-foo:(int)class { // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
45
+
}
46
+
47
+
@end
48
+
49
+
@implementationclass// expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
50
+
@end
51
+
52
+
@implementationBar: class// expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
53
+
@end
54
+
55
+
@compatibility_alias C Foo; // ok
56
+
@compatibility_alias const_cast Bar; // expected-error {{expected identifier; 'const_cast' is a keyword in Objective-C++}}
57
+
@compatibility_alias C2 class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
58
+
59
+
voidfunc() {
60
+
(void)@protocol(P); // ok
61
+
(void)@protocol(delete); // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
0 commit comments