[cfe-commits] r99230 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/property-in-class-extension.m

Fariborz Jahanian fjahanian at apple.com
Mon Mar 22 16:25:52 PDT 2010


Author: fjahanian
Date: Mon Mar 22 18:25:52 2010
New Revision: 99230

URL: http://llvm.org/viewvc/llvm-project?rev=99230&view=rev
Log:
Set the relevent attributes declared in class extension
and fix a missing diagnostics on assigning to a read-only
property. Fixes radar 7766184.


Added:
    cfe/trunk/test/SemaObjC/property-in-class-extension.m
Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=99230&r1=99229&r2=99230&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Mon Mar 22 18:25:52 2010
@@ -93,6 +93,11 @@
   ObjCPropertyDecl *PDecl =
     ObjCPropertyDecl::Create(Context, DC, FD.D.getIdentifierLoc(),
                              PropertyId, AtLoc, T);
+  if (Attributes & ObjCDeclSpec::DQ_PR_readonly)
+    PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
+  if (Attributes & ObjCDeclSpec::DQ_PR_readwrite)
+    PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
+
   DC->addDecl(PDecl);
 
   // We need to look in the @interface to see if the @property was

Added: cfe/trunk/test/SemaObjC/property-in-class-extension.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-in-class-extension.m?rev=99230&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/property-in-class-extension.m (added)
+++ cfe/trunk/test/SemaObjC/property-in-class-extension.m Mon Mar 22 18:25:52 2010
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+// rdar: // 7766184
+
+ at interface Foo @end
+
+ at interface Foo ()
+  @property (readonly) int bar;
+ at end
+
+void FUNC () {
+    Foo *foo;
+    foo.bar = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+}
+
+





More information about the cfe-commits mailing list