def error_property_ivar_type : Error<
"type of property %0 does not match type of ivar %1">;
+def error_ivar_in_superclass_use : Error<
+ "property %0 attempting to use ivar %1 declared in in super class %2">;
def error_weak_property : Error<
"existing ivar %1 for __weak property %0 must be __weak">;
def error_strong_property : Error<
// 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());
// Check that this is a previously declared 'ivar' in 'IDecl' interface
- Ivar = IDecl->lookupInstanceVariable(Context, PropertyIvar);
+ ObjCInterfaceDecl *ClassDeclared;
+ Ivar = IDecl->lookupInstanceVariable(Context, PropertyIvar, ClassDeclared);
if (!Ivar) {
if (getLangOptions().ObjCNonFragileABI) {
Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc,
return DeclPtrTy();
}
}
+ else if (getLangOptions().ObjCNonFragileABI &&
+ NoExplicitPropertyIvar && ClassDeclared != IDecl) {
+ Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
+ << property->getDeclName() << Ivar->getDeclName()
+ << ClassDeclared->getDeclName();
+ Diag(Ivar->getLocation(), diag::note_previous_access_declaration)
+ << Ivar << Ivar->getNameAsCString();
+ // Note! I deliberately want it to fall thru so more errors are caught.
+ }
QualType IvarType = Context.getCanonicalType(Ivar->getType());
// Check that type of property and its ivar are type compatible.
--- /dev/null
+// RUN: clang-cc -fsyntax-only -triple x86_64-apple-darwin10 -verify %s
+
+@interface Super {
+ id value; // expected-note {{previously declared 'value' here}}
+}
+@property(retain) id value;
+@property(retain) id value1;
+@end
+
+@interface Sub : Super @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'}}
+@end
+
+