aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-12-16 00:56:28 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-12-16 00:56:28 +0000
commit8b1aba495744bea7093899a65f08c3987263061c (patch)
treee9622851ab65c284e33d682b367facd3984f3369
parent56c04588ef3cfa1bbc968fd68de2480a4e66971d (diff)
Improve diagnostics when property being looked up
in a forward @class object. // rdar://8774513 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121933 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--lib/Sema/SemaExprObjC.cpp6
-rw-r--r--test/SemaObjC/property-9.m11
3 files changed, 21 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index e9617a2f11..8095b94656 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 5d5e8a528b..baa34f9ce8 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -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.
diff --git a/test/SemaObjC/property-9.m b/test/SemaObjC/property-9.m
index 669f9c0e4b..2b6564d295 100644
--- a/test/SemaObjC/property-9.m
+++ b/test/SemaObjC/property-9.m
@@ -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 *'}}
+}
+