]> granicus.if.org Git - clang/commitdiff
Fix for PR3234
authorAnders Carlsson <andersca@mac.com>
Fri, 19 Dec 2008 17:27:57 +0000 (17:27 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 19 Dec 2008 17:27:57 +0000 (17:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61245 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaExpr.cpp
test/SemaObjC/property-missing.m [new file with mode: 0644]

index 39464efd6aec760ae8a16da6c57cdb5a2fbcf83f..6b11d31701dcdf9c7ee8b4de0c08bc7e8d98f032 100644 (file)
@@ -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,
index 3ee601faca82340512db58b8f6a5ef8f0d4f3969..d31855e36bdaf721ade46469b2dc8497396486e3 100644 (file)
@@ -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/test/SemaObjC/property-missing.m b/test/SemaObjC/property-missing.m
new file mode 100644 (file)
index 0000000..23af006
--- /dev/null
@@ -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}}
+}
+