]> granicus.if.org Git - clang/commitdiff
use of an ivar specified on a property @synthesize
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 29 Apr 2009 21:45:02 +0000 (21:45 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 29 Apr 2009 21:45:02 +0000 (21:45 +0000)
and found in super class triggers a diagnostics.

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

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/ivar-sem-check-2.m

index da50573f23bff4580658239eacce0f903c421763..7eea4ff93e1bc436ffcd187ba9918b497b88dd9d 100644 (file)
@@ -1895,7 +1895,6 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
   // Check that we have a valid, previously declared ivar for @synthesize
   if (Synthesize) {
     // @synthesize
-    bool NoExplicitPropertyIvar = (!PropertyIvar);
     if (!PropertyIvar)
       PropertyIvar = PropertyId;
     QualType PropType = Context.getCanonicalType(property->getType());
@@ -1914,7 +1913,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
         // a property implementation and to avoid future warnings.
     }
     else if (getLangOptions().ObjCNonFragileABI &&
-             NoExplicitPropertyIvar && ClassDeclared != IDecl) {
+             ClassDeclared != IDecl) {
       Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
         << property->getDeclName() << Ivar->getDeclName() 
         << ClassDeclared->getDeclName();
index 2b85685362d30a801a7394102cc9a8c0ce063fd1..6a703b24f3c5806899b341c6b821d14665124296 100644 (file)
@@ -1,17 +1,23 @@
 // RUN: clang-cc  -fsyntax-only -triple x86_64-apple-darwin10 -verify %s
 
 @interface Super  {
-  id value; // expected-note {{previously declared 'value' here}}
+  id value2; // expected-note {{previously declared 'value2' here}}
 } 
 @property(retain) id value;
 @property(retain) id value1;
+@property(retain) id prop;
 @end
 
-@interface Sub : Super @end
+@interface Sub : Super 
+{
+  id value; 
+}
+@end
 
 @implementation Sub
-@synthesize value; // expected-error {{property 'value' attempting to use ivar 'value' declared in in super class 'Super'}} // expected-note {{previous use is here}}
-@synthesize value1=value; // expected-error {{synthesized properties 'value1' and 'value' both claim ivar 'value'}}
+@synthesize value; // expected-note {{previous use is here}}
+@synthesize value1=value; // expected-error {{synthesized properties 'value1' and 'value' both claim ivar 'value'}} 
+@synthesize prop=value2;  // expected-error {{property 'prop' attempting to use ivar 'value2' declared in in super class 'Super'}}
 @end