forked from OSchip/llvm-project
Improve diagnostics when property being looked up
in a forward @class object. // rdar://8774513 llvm-svn: 121933
This commit is contained in:
parent
9613a09e5c
commit
7cabbe04eb
|
@ -2416,6 +2416,10 @@ def err_ref_array_type : Error<
|
|||
"cannot refer to declaration with an array type inside block">;
|
||||
def err_property_not_found : Error<
|
||||
"property %0 not found on object of type %1">;
|
||||
def err_property_not_found_forward_class : Error<
|
||||
"property %0 cannot be found in forward class object %1">;
|
||||
def note_forward_class : Note<
|
||||
"forward class is declared here">;
|
||||
def err_duplicate_property : Error<
|
||||
"property has a previous declaration">;
|
||||
def ext_gnu_void_ptr : Extension<
|
||||
|
|
|
@ -353,6 +353,12 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
|
|||
ObjCInterfaceDecl *IFace = IFaceT->getDecl();
|
||||
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
|
||||
|
||||
if (IFace->isForwardDecl()) {
|
||||
Diag(MemberLoc, diag::err_property_not_found_forward_class)
|
||||
<< MemberName << QualType(OPT, 0);
|
||||
Diag(IFace->getLocation(), diag::note_forward_class);
|
||||
return ExprError();
|
||||
}
|
||||
// Search for a declared property first.
|
||||
if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Member)) {
|
||||
// Check whether we can reference this property.
|
||||
|
|
|
@ -96,3 +96,14 @@ typedef signed char BOOL;
|
|||
- (float)setMyStyle:(int)style;
|
||||
@end
|
||||
|
||||
// rdar://8774513
|
||||
@class MDAInstance; // expected-note {{forward class is declared here}}
|
||||
|
||||
@interface MDATestDocument
|
||||
@property(retain) MDAInstance *instance;
|
||||
@end
|
||||
|
||||
id f0(MDATestDocument *d) {
|
||||
return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance *'}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue