diff options
author | Anders Carlsson <andersca@mac.com> | 2008-12-19 17:27:57 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-12-19 17:27:57 +0000 |
commit | 324de7ba46c961e5cce879f30f9be57a040c6a3e (patch) | |
tree | cc9f6652130241447f26ac2b1d319c5844b75ccd | |
parent | 9c148c8fc280b5dbf365b2235556f4869a309565 (diff) | |
download | bcm5719-llvm-324de7ba46c961e5cce879f30f9be57a040c6a3e.tar.gz bcm5719-llvm-324de7ba46c961e5cce879f30f9be57a040c6a3e.zip |
Fix for PR3234
llvm-svn: 61245
-rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaObjC/property-missing.m | 22 |
3 files changed, 30 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 39464efd6ae..6b11d31701d 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -458,6 +458,8 @@ DIAG(err_objc_property_requires_object, ERROR, "property with '%0' attribute must be of object type") DIAG(err_property_type, ERROR, "property cannot have array or function type %0") +DIAG(err_property_not_found, ERROR, + "property %0 not found on object of type %1") DIAG(err_objc_directive_only_in_protocol, ERROR, "directive may only be specified in protocols only") DIAG(err_missing_catch_finally, ERROR, diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3ee601faca8..d31855e36bd 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1348,6 +1348,9 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, return new ObjCKVCRefExpr(Getter, Getter->getResultType(), Setter, MemberLoc, BaseExpr); } + + return Diag(MemberLoc, diag::err_property_not_found) << + &Member << BaseType; } // Handle properties on qualified "id" protocols. const ObjCQualifiedIdType *QIdTy; @@ -1364,6 +1367,9 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, OpLoc, MemberLoc, NULL, 0); } } + + return Diag(MemberLoc, diag::err_property_not_found) << + &Member << BaseType; } // Handle 'field access' to vectors, such as 'V.xx'. if (BaseType->isExtVectorType() && OpKind == tok::period) { diff --git a/clang/test/SemaObjC/property-missing.m b/clang/test/SemaObjC/property-missing.m new file mode 100644 index 00000000000..23af00646a9 --- /dev/null +++ b/clang/test/SemaObjC/property-missing.m @@ -0,0 +1,22 @@ +// RUN: clang -fsyntax-only -verify %s + +// PR3234 + +@protocol NSCopying @end +@interface NSObject @end + +void f1(NSObject *o) +{ + o.foo; // expected-error{{property 'foo' not found on object of type 'NSObject *'}} +} + +void f2(id<NSCopying> o) +{ + o.foo; // expected-error{{property 'foo' not found on object of type 'id<NSCopying>'}} +} + +void f3(id o) +{ + o.foo; // expected-error{{member reference base type 'id' is not a structure or union}} +} + |