]> granicus.if.org Git - clang/commitdiff
Diagnose if type of iboutletcollection attribute is a builtin type.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Aug 2010 23:19:16 +0000 (23:19 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Aug 2010 23:19:16 +0000 (23:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111324 91177308-0d34-0410-b5e6-96231b3b80d8

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

index dd4f1fcc5763525ee4eb22786006a57a843ffef5..ed0f9b0fefc96467d4b551ba0b1a9076d7002609 100644 (file)
@@ -103,6 +103,8 @@ def err_expected_member_name_or_semi : Error<
   "expected member name or ';' after declaration specifiers">;
 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_expected_fn_body : Error<
   "expected function body after function declarator">;
 def err_expected_method_body : Error<"expected method body">;
index 7149d4dc3029d06106d797f36d6d7fa4d770f956..ce0377020a4da1de4cc15e88f26585108af48882 100644 (file)
@@ -174,11 +174,13 @@ AttributeList *Parser::ParseGNUAttributes(SourceLocation *EndLoc) {
           case tok::kw_double:
           case tok::kw_void:
           case tok::kw_typeof:
+            CurrAttr = new AttributeList(AttrName, AttrNameLoc, 0, AttrNameLoc,
+                                         0, SourceLocation(), 0, 0, CurrAttr);
+            if (CurrAttr->getKind() == AttributeList::AT_IBOutletCollection)
+              Diag(Tok, diag::err_iboutletcollection_builtintype);
             // If it's a builtin type name, eat it and expect a rparen
             // __attribute__(( vec_type_hint(char) ))
             ConsumeToken();
-            CurrAttr = new AttributeList(AttrName, AttrNameLoc, 0, AttrNameLoc,
-                                         0, SourceLocation(), 0, 0, CurrAttr);
             if (Tok.is(tok::r_paren))
               ConsumeParen();
             break;
index 0db4a571fde479f890d6b81fd89c7c6512c9c3a0..159da36d021ae49d514ddc6c187b73fcee43ec2a 100644 (file)
@@ -20,6 +20,7 @@ typedef void *PV;
     __attribute__((iboutletcollection(B))) id ivar2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribue}}
     __attribute__((iboutletcollection(PV))) id ivar3; // expected-error {{invalid type 'PV' as argument of iboutletcollection attribue}}
     __attribute__((iboutletcollection(PV))) void *ivar4; // expected-error {{ivar with iboutletcollection attribue must have object type (invalid 'void *')}}
+    __attribute__((iboutletcollection(int))) id ivar5; // expected-error {{type argument of iboutletcollection attribute cannot be a builtin type}}
 }
 @property (nonatomic, retain) __attribute__((iboutletcollection(I,2,3))) id prop1; // expected-error {{attribute requires 1 argument(s)}}
 @property (nonatomic, retain) __attribute__((iboutletcollection(B))) id prop2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribue}}