objective-c: Fixes a corner case and interesting bug.

Where diagnostic about unfound property is not
issued in the context where a setter is looked up
in situation in which name and property name differ 
in their first letter case. // rdar://11363363

llvm-svn: 157407
This commit is contained in:
Fariborz Jahanian 2012-05-24 18:29:41 +00:00
parent 6fef6e6466
commit 246f519a51
2 changed files with 34 additions and 1 deletions

View File

@ -1415,7 +1415,8 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
return ExprError();
// Search for a declared property first.
if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Member)) {
ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Member);
if (PD) {
// Check whether we can reference this property.
if (DiagnoseUseOfDecl(PD, MemberLoc))
return ExprError();
@ -1483,6 +1484,10 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), Member);
ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
// Check for corner case of: @property int p; ... self.P = 0;
// setter name is synthesized "setP" but there is no property name 'P'.
if (Setter && Setter->isSynthesized() && !PD)
Setter = 0;
// May be founf in property's qualified list.
if (!Setter)

View File

@ -102,3 +102,31 @@ int main (void) {
abort ();
return 0;
}
// rdar://11363363
@interface rdar11363363
{
id R;
}
@property (copy) id p;
@property (copy) id r;
@property (copy) id Q;
@property (copy) id t;
@property (copy) id T;
@end
@implementation rdar11363363
@synthesize p;
@synthesize r;
@synthesize Q;
@synthesize t, T;
- (id) Meth {
self.P = 0; // expected-error {{property 'P' not found on object of type 'rdar11363363 *'}}
self.q = 0; // expected-error {{property 'q' not found on object of type 'rdar11363363 *'}}
self.t = 0; // OK
self.T = 0; // OK
self.R = 0; // expected-error {{property 'R' not found on object of type 'rdar11363363 *'; did you mean to access ivar 'R'?}}
return self.R; // expected-error {{property 'R' not found on object of type 'rdar11363363 *'; did you mean to access ivar 'R'?}}
}
@end