зеркало из https://github.com/microsoft/clang-1.git
In objc2's None-Fragile ABI, one cannot use the super class ivar for
setter/getter synthesis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68976 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
aa4a756185
Коммит
29da66ec56
|
@ -212,6 +212,8 @@ def error_synthesized_ivar_yet_not_supported : Error<
|
|||
|
||||
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<
|
||||
|
|
|
@ -1791,11 +1791,13 @@ 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());
|
||||
// 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,
|
||||
|
@ -1809,6 +1811,15 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
|
|||
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.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// 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
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче