r271688 - Obj-C: Fix assert-on-invalid (PR27822)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 09:59:13 PDT 2016


Author: hans
Date: Fri Jun  3 11:59:13 2016
New Revision: 271688

URL: http://llvm.org/viewvc/llvm-project?rev=271688&view=rev
Log:
Obj-C: Fix assert-on-invalid (PR27822)

Clang would assert when isObjCInstancetype() was called on a
tok::annot_cxxscope token.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/test/SemaObjCXX/instancetype.mm

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=271688&r1=271687&r2=271688&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jun  3 11:59:13 2016
@@ -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;

Modified: cfe/trunk/test/SemaObjCXX/instancetype.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/instancetype.mm?rev=271688&r1=271687&r2=271688&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/instancetype.mm (original)
+++ cfe/trunk/test/SemaObjCXX/instancetype.mm Fri Jun  3 11:59:13 2016
@@ -214,3 +214,10 @@ void test_instancetype_inherited() {
   return 0;
 }
 @end
+
+// PR27822
+ at class NSString;
+namespace pr27822 { }
+ at interface AXPlatformNodeCocoa
++ (NSString*)nativeRoleFromAXRole:(pr27822::UndeclaredIdentifier)role; // expected-error {{expected a type}}
+ at end




More information about the cfe-commits mailing list