]> granicus.if.org Git - clang/commitdiff
Diagnose property of reference type as unsupported
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Dec 2009 18:03:30 +0000 (18:03 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 16 Dec 2009 18:03:30 +0000 (18:03 +0000)
instead of crashing for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91546 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclObjC.cpp
test/SemaObjCXX/references.mm

index 37d80e15e4d308d92630539f86b67b73bbfcc012..2c3f85f2be3606554a59168a02ca17556a12a029 100644 (file)
@@ -305,6 +305,8 @@ def note_property_declare : Note<
   "property declared here">;
 def error_synthesize_category_decl : Error<
   "@synthesize not allowed in a category's implementation">;
+def error_reference_property : Error<
+  "property of reference type is not supported">;
 def error_missing_property_interface : Error<
   "property implementation in a category with no category declaration">;
 def error_bad_category_property_decl : Error<
index a768e1bdf7819ccd967a70736fb4fbf098dd4bca..ea7d9a93858317f91544dc31aae90408913fca26 100644 (file)
@@ -1950,6 +1950,10 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
                     !(Attributes & ObjCDeclSpec::DQ_PR_retain) &&
                     !(Attributes & ObjCDeclSpec::DQ_PR_copy)));
   QualType T = GetTypeForDeclarator(FD.D, S);
+  if (T->isReferenceType()) {
+    Diag(AtLoc, diag::error_reference_property);
+    return DeclPtrTy();
+  }
   Decl *ClassDecl = ClassCategory.getAs<Decl>();
   ObjCInterfaceDecl *CCPrimary = 0; // continuation class's primary class
   // May modify Attributes.
index ded385cba14a09775d1ad1c96122c9abd29b7f49..70ce8278e8f0c6caad0177eccac2c0dda0adee45 100644 (file)
@@ -1,7 +1,4 @@
-// FIXME: This crashes, disable it until fixed.
-// RN: %clang_cc1 -verify -emit-llvm -o - %s
-// RUN: false
-// XFAIL: *
+// RUN: %clang_cc1 -verify -emit-llvm -o - %s
 
 // Test reference binding.
 
@@ -12,7 +9,7 @@ typedef struct {
 
 @interface A
 @property (assign) T p0;
-@property (assign) T& p1;
+@property (assign) T& p1; // expected-error {{property of reference type is not supported}}
 @end
 
 int f0(const T& t) {
@@ -24,6 +21,6 @@ int f1(A *a) {
 }
 
 int f2(A *a) {
-  return f0(a.p1);
+  return f0(a.p1);     // expected-error {{property 'p1' not found on object of type 'A *'}}
 }