]> granicus.if.org Git - clang/commitdiff
objc: diagnose invalid argument to an
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 18 Oct 2011 17:11:10 +0000 (17:11 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 18 Oct 2011 17:11:10 +0000 (17:11 +0000)
iboutletcollection attribute intead of crashing.
// rdar://10296078

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

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseDecl.cpp
test/SemaObjC/iboutletcollection-attr.m

index b1cb8935ffb3b4ea448ed1905c386ef7059c4f88..62470582870cadd9ca0554c95a3b11d3bd1f6549 100644 (file)
@@ -138,7 +138,8 @@ def err_function_declared_typedef : Error<
   "function definition declared 'typedef'">;
 def err_iboutletcollection_builtintype : Error<
   "type argument of iboutletcollection attribute cannot be a builtin type">;
-
+def err_iboutletcollection_with_protocol : Error<
+  "invalid argument of iboutletcollection attribute">;
 def err_at_defs_cxx : Error<"@defs is not supported in Objective-C++">;
 def err_at_in_class : Error<"unexpected '@' in member specification">;
 
index 3f4f4f8375584ef71ed3300a8763d892a2d23dd4..0c60e287414eaf964456e82977e8250eabe194ac 100644 (file)
@@ -245,6 +245,13 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName,
       ConsumeToken(); // Eat the comma, move to the next argument
     }
   }
+  else if (Tok.is(tok::less) && AttrName->isStr("iboutletcollection")) {
+    if (!ExpectAndConsume(tok::less, diag::err_expected_less_after, "<",
+                          tok::greater)) {
+      Diag(Tok, diag::err_iboutletcollection_with_protocol);
+      SkipUntil(tok::r_paren, false, true); // skip until ')'
+    }
+  }
 
   SourceLocation RParen = Tok.getLocation();
   if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) {
index 6bfe3138954681f4a41a9983c8ee727474c11efa..052fe9fb00b56e874648342ea86570ea7e07ec95 100644 (file)
@@ -29,3 +29,13 @@ typedef void *PV;
 @property __attribute__((iboutletcollection(BAD))) int prop3; // expected-error {{property with 'iboutletcollection' attribute must be an object type (invalid 'int')}}
 @end
 
+// rdar://10296078
+@interface ParentRDar10296078 @end
+@class NSArray;
+@protocol RDar10296078_Protocol;
+@class RDar10296078_OtherClass;
+
+@interface RDar10296078  : ParentRDar10296078
+@property (nonatomic, strong) 
+  __attribute__((iboutletcollection(RDar10296078_OtherClass<RDar10296078_Protocol>))) NSArray *stuff; // expected-error {{invalid argument of iboutletcollection attribute}}
+@end