[llvm-branch-commits] [cfe-branch] r120659 - in /cfe/branches/Apple/whitney: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/duplicate-property-class-extension.m

Daniel Dunbar daniel at zuster.org
Wed Dec 1 18:51:56 PST 2010


Author: ddunbar
Date: Wed Dec  1 20:51:56 2010
New Revision: 120659

URL: http://llvm.org/viewvc/llvm-project?rev=120659&view=rev
Log:
Merge r118689:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date:   Wed Nov 10 18:01:36 2010 +0000

    Check for duplicate declaration of a property in current and
    other class extensions. // rdar://7629420

Modified:
    cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp
    cfe/branches/Apple/whitney/test/SemaObjC/duplicate-property-class-extension.m

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp?rev=120659&r1=120658&r2=120659&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaObjCProperty.cpp Wed Dec  1 20:51:56 2010
@@ -93,14 +93,22 @@
   // Diagnose if this property is already in continuation class.
   DeclContext *DC = cast<DeclContext>(CDecl);
   IdentifierInfo *PropertyId = FD.D.getIdentifier();
-
-  if (ObjCPropertyDecl *prevDecl =
-        ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) {
-    Diag(AtLoc, diag::err_duplicate_property);
-    Diag(prevDecl->getLocation(), diag::note_property_declare);
-    return 0;
-  }
-
+  ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface();
+  
+  if (CCPrimary)
+    // Check for duplicate declaration of this property in current and
+    // other class extensions.
+    for (const ObjCCategoryDecl *ClsExtDecl = 
+         CCPrimary->getFirstClassExtension();
+         ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) {
+      if (ObjCPropertyDecl *prevDecl =
+          ObjCPropertyDecl::findPropertyDecl(ClsExtDecl, PropertyId)) {
+        Diag(AtLoc, diag::err_duplicate_property);
+        Diag(prevDecl->getLocation(), diag::note_property_declare);
+        return 0;
+      }
+    }
+  
   // Create a new ObjCPropertyDecl with the DeclContext being
   // the class extension.
   ObjCPropertyDecl *PDecl =
@@ -115,7 +123,6 @@
 
   // We need to look in the @interface to see if the @property was
   // already declared.
-  ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface();
   if (!CCPrimary) {
     Diag(CDecl->getLocation(), diag::err_continuation_class);
     *isOverridingProperty = true;

Modified: cfe/branches/Apple/whitney/test/SemaObjC/duplicate-property-class-extension.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaObjC/duplicate-property-class-extension.m?rev=120659&r1=120658&r2=120659&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaObjC/duplicate-property-class-extension.m (original)
+++ cfe/branches/Apple/whitney/test/SemaObjC/duplicate-property-class-extension.m Wed Dec  1 20:51:56 2010
@@ -1,23 +1,24 @@
 // RUN: %clang_cc1  -fsyntax-only -verify %s
+// rdar://7629420
 
 @interface Foo 
- at property (readonly) char foo; // expected-note {{property declared here}}
+ at property (readonly) char foo; 
 @property (readwrite) char bar; // expected-note {{property declared here}}
 @end
 
 @interface Foo ()
- at property (readwrite) char foo; // OK 
+ at property (readwrite) char foo; // expected-note 2 {{property declared here}} 
 @property (readwrite) char NewProperty; // expected-note 2 {{property declared here}} 
 @property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in continuation class 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}}
 @end
 
 @interface Foo ()
- at property (readwrite) char foo;	//  OK again, make primary property readwrite for 2nd time!
- at property (readwrite) char NewProperty; // expected-error {{redeclaration of property in continuation class 'Foo' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+ at property (readwrite) char foo;	 // expected-error {{property has a previous declaration}}
+ at property (readwrite) char NewProperty; // expected-error {{property has a previous declaration}}
 @end
 
 @interface Foo ()
- at property (readonly) char foo; // expected-error {{redeclaration of property in continuation class 'Foo' (attribute must be 'readwrite', while its primary must be 'readonly')}}
- at property (readwrite) char NewProperty; // expected-error {{redeclaration of property in continuation class 'Foo' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+ at property (readonly) char foo; // expected-error {{property has a previous declaration}}
+ at property (readwrite) char NewProperty; // expected-error {{property has a previous declaration}}
 @end
 





More information about the llvm-branch-commits mailing list