[cfe-commits] r61090 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-typecheck-2.m

Fariborz Jahanian fjahanian at apple.com
Tue Dec 16 09:51:03 PST 2008


Author: fjahanian
Date: Tue Dec 16 11:51:01 2008
New Revision: 61090

URL: http://llvm.org/viewvc/llvm-project?rev=61090&view=rev
Log:
Patch to check for ObjC's property type.

Added:
    cfe/trunk/test/SemaObjC/property-typecheck-2.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=61090&r1=61089&r2=61090&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Tue Dec 16 11:51:01 2008
@@ -456,6 +456,8 @@
      "default property attribute 'assign' not appropriate for non-gc object")
 DIAG(err_objc_property_requires_object, ERROR,
      "property with '%0' attribute must be of object type")
+DIAG(err_property_type, ERROR,
+     "property cannot have type %0 (array or function type)")
 DIAG(err_objc_directive_only_in_protocol, ERROR,
      "directive may only be specified in protocols only")
 DIAG(err_missing_catch_finally, ERROR,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=61090&r1=61089&r2=61090&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Dec 16 11:51:01 2008
@@ -1437,6 +1437,10 @@
       }
     }
 
+  Type *t = T.getTypePtr();
+  if (t->isArrayType() || t->isFunctionType())
+    Diag(AtLoc, diag::err_property_type) << T;
+  
   ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc, 
                                                      FD.D.getIdentifier(), T);
   // Regardless of setter/getter attribute, we save the default getter/setter

Added: cfe/trunk/test/SemaObjC/property-typecheck-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-typecheck-2.m?rev=61090&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/property-typecheck-2.m (added)
+++ cfe/trunk/test/SemaObjC/property-typecheck-2.m Tue Dec 16 11:51:01 2008
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only -verify %s
+
+typedef int T[2];
+typedef void (F)(void);
+
+ at interface A
+ at property(assign) T p2;  // expected-error {{property cannot have type 'T' (array or function type)}}
+
+ at property(assign) F f2; // expected-error {{property cannot have type 'F' (array or function type)}}
+
+ at end
+





More information about the cfe-commits mailing list