]> granicus.if.org Git - clang/commitdiff
objc++: Accessing explicit property of reference type need
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Oct 2011 17:58:21 +0000 (17:58 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 3 Oct 2011 17:58:21 +0000 (17:58 +0000)
not bind to a temporary. Fixes //rdar://10188258

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

lib/Sema/SemaExpr.cpp
test/CodeGenObjCXX/property-object-reference.mm [new file with mode: 0644]

index 1675568a56a3dcc00578964f996a7080467c4b5a..707d577f6136fac37f2659265ef1020bfccf595b 100644 (file)
@@ -7388,7 +7388,13 @@ ExprResult Sema::ConvertPropertyForRValue(Expr *E) {
             << PRE->getBase()->getType();
     }
   }
-  
+  else {
+    // lvalue-ness of an explicit property is determined by
+    // property type.
+    ObjCPropertyDecl *PDecl = PRE->getExplicitProperty();
+    VK = Expr::getValueKindForType(PDecl->getType());
+  }
+    
   E = ImplicitCastExpr::Create(Context, T, CK_GetObjCProperty,
                                E, 0, VK);
   
diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm
new file mode 100644 (file)
index 0000000..b87ce23
--- /dev/null
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s
+// rdar://10188258
+
+struct Foo {int i;};
+
+@interface ObjCTest  { }
+@property (nonatomic, readonly) Foo& FooRefProperty;
+@end
+
+
+@implementation ObjCTest
+@dynamic FooRefProperty;
+
+-(void) test {
+    Foo& f = self.FooRefProperty;
+}
+@end
+
+// CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]]
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK:  [[T2:%.*]]  = bitcast {{%.*}} [[T0]] to i8*
+// CHECK:  @objc_msgSend
+