]> granicus.if.org Git - clang/commitdiff
Obj-C: Fix assert-on-invalid (PR27822)
authorHans Wennborg <hans@hanshq.net>
Fri, 3 Jun 2016 16:59:13 +0000 (16:59 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 3 Jun 2016 16:59:13 +0000 (16:59 +0000)
Clang would assert when isObjCInstancetype() was called on a
tok::annot_cxxscope token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271688 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Parser.h
test/SemaObjCXX/instancetype.mm

index f4688798055703f3c9b1df97dd12b197dff9df25..9cbad6b634dab90abe8bf51e2b84bfd97cb2f511 100644 (file)
@@ -647,6 +647,8 @@ private:
   /// Should only be used in Objective-C language modes.
   bool isObjCInstancetype() {
     assert(getLangOpts().ObjC1);
+    if (Tok.isAnnotation())
+      return false;
     if (!Ident_instancetype)
       Ident_instancetype = PP.getIdentifierInfo("instancetype");
     return Tok.getIdentifierInfo() == Ident_instancetype;
index 89ff2b4b0326623e7b226231f02af45eb1ffed43..f61d6bf4cfc814cccdef19b076d11b3f8eed9f0f 100644 (file)
@@ -214,3 +214,10 @@ void test_instancetype_inherited() {
   return 0;
 }
 @end
+
+// PR27822
+@class NSString;
+namespace pr27822 { }
+@interface AXPlatformNodeCocoa
++ (NSString*)nativeRoleFromAXRole:(pr27822::UndeclaredIdentifier)role; // expected-error {{expected a type}}
+@end