[cfe-commits] r121933 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp test/SemaObjC/property-9.m
Fariborz Jahanian
fjahanian at apple.com
Wed Dec 15 16:56:28 PST 2010
Author: fjahanian
Date: Wed Dec 15 18:56:28 2010
New Revision: 121933
URL: http://llvm.org/viewvc/llvm-project?rev=121933&view=rev
Log:
Improve diagnostics when property being looked up
in a forward @class object. // rdar://8774513
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/property-9.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=121933&r1=121932&r2=121933&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 15 18:56:28 2010
@@ -2416,6 +2416,10 @@
"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<
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=121933&r1=121932&r2=121933&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Dec 15 18:56:28 2010
@@ -353,6 +353,12 @@
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.
Modified: cfe/trunk/test/SemaObjC/property-9.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-9.m?rev=121933&r1=121932&r2=121933&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-9.m (original)
+++ cfe/trunk/test/SemaObjC/property-9.m Wed Dec 15 18:56:28 2010
@@ -96,3 +96,14 @@
- (float)setMyStyle:(int)style;
@end
+// rdar://8774513
+ at class MDAInstance; // expected-note {{forward class is declared here}}
+
+ at interface MDATestDocument
+ at property(retain) MDAInstance *instance;
+ at end
+
+id f0(MDATestDocument *d) {
+ return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance *'}}
+}
+
More information about the cfe-commits
mailing list