aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-11-01 18:57:34 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-11-01 18:57:34 +0000
commit0505321691aa39105ecd2f92bb64cdaa932fbf08 (patch)
tree22539286cc3286a7002b256ff27393f2af7b4abb
parent2eb0ce3610a877f75e95c66d6c2bff315e127009 (diff)
Find copy constructor needed to copy an rvalue reference
c++ object into block descriptor. // rdar://9971124 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143475 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp5
-rw-r--r--test/CodeGenCXX/block-rvalue-reference-capture.cpp15
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 61766a88c0..d4d08703d3 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1304,7 +1304,10 @@ static CaptureResult shouldCaptureValueReference(Sema &S, SourceLocation loc,
// Okay, we descended all the way to the block that defines the variable.
// Actually try to capture it.
QualType type = var->getType();
-
+
+ if (type->isRValueReferenceType())
+ type = type->getPointeeType();
+
// Prohibit variably-modified types.
if (type->isVariablyModifiedType()) {
S.Diag(loc, diag::err_ref_vm_type);
diff --git a/test/CodeGenCXX/block-rvalue-reference-capture.cpp b/test/CodeGenCXX/block-rvalue-reference-capture.cpp
index df99e42177..997e14f851 100644
--- a/test/CodeGenCXX/block-rvalue-reference-capture.cpp
+++ b/test/CodeGenCXX/block-rvalue-reference-capture.cpp
@@ -14,3 +14,18 @@ int main() {
// CHECK: [[C:%.*]] = getelementptr inbounds <{ {{.*}} i32 }>* [[B]]
// CHECK: [[R:%.*]] = load i32* [[C]], align 4
// CHECK: ret i32 [[R]]
+
+class S {
+public:
+ S (const S &);
+ S(int);
+ int field;
+};
+
+int func(S && rv)
+{
+ return ^{ return rv.field; }();
+}
+
+// CHECK: define i32 @_Z4funcO1S
+// CHECK: call void @_ZN1SC1ERKS_