Type of property and its ivar is more restrictive

that rules for assignment.

llvm-svn: 62524
This commit is contained in:
Fariborz Jahanian 2009-01-19 20:13:47 +00:00
parent 19e953acd9
commit 54fa418d03
2 changed files with 29 additions and 0 deletions

View File

@ -1698,6 +1698,21 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
<< property->getDeclName() << Ivar->getDeclName();
return 0;
}
else {
// FIXME! Rules for properties are somewhat different that those
// for assignments. Use a new routine to consolidate all cases;
// specifically for property redeclarations as well as for ivars.
QualType lhsType =
Context.getCanonicalType(PropType).getUnqualifiedType();
QualType rhsType =
Context.getCanonicalType(IvarType).getUnqualifiedType();
if (lhsType != rhsType &&
lhsType->isArithmeticType()) {
Diag(PropertyLoc, diag::error_property_ivar_type)
<< property->getDeclName() << Ivar->getDeclName();
return 0;
}
}
}
} else if (PropertyIvar) {
// @dynamic

View File

@ -0,0 +1,14 @@
// RUN: clang -fsyntax-only -verify %s
// Test that arithmatic types on property and its ivar have exact match.
@interface Test4
{
char ivar;
}
@property int prop;
@end
@implementation Test4
@synthesize prop = ivar; // expected-error {{type of property 'prop' does not match type of ivar 'ivar'}}
@end