summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/reference-init.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-02-23 22:41:47 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-02-23 22:41:47 +0000
commitfad0d791961d3f29e5340bba709be214c53e9d13 (patch)
tree325072b0feee96d38e3510c32cdcba576d909b22 /test/CodeGenCXX/reference-init.cpp
parent0df4330a24251e7d19550819018be741e4b4b3e0 (diff)
PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/reference-init.cpp')
-rw-r--r--test/CodeGenCXX/reference-init.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/CodeGenCXX/reference-init.cpp b/test/CodeGenCXX/reference-init.cpp
index 3a3eaeee78..ba7b282028 100644
--- a/test/CodeGenCXX/reference-init.cpp
+++ b/test/CodeGenCXX/reference-init.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++98 | FileCheck %s --check-prefix=CHECK-CXX98
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++11 | FileCheck %s --check-prefix=CHECK-CXX11
// expected-no-diagnostics
struct XPTParamDescriptor {};
@@ -23,3 +25,12 @@ Foo& ignoreSetMutex = *(new Foo);
// Binding to a bit-field that requires a temporary.
struct { int bitfield : 3; } s = { 3 };
const int &s2 = s.bitfield;
+
+// In C++98, this forms a reference to itself. In C++11 onwards, this performs
+// copy-construction.
+struct SelfReference { SelfReference &r; };
+extern SelfReference self_reference_1;
+SelfReference self_reference_2 = {self_reference_1};
+// CHECK-CXX98: @self_reference_2 = global %[[SELF_REF:.*]] { %[[SELF_REF]]* @self_reference_1 }
+// CHECK-CXX11: @self_reference_2 = global %[[SELF_REF:.*]] zeroinitializer
+// CHECK-CXX11: call {{.*}}memcpy{{.*}} @self_reference_2 {{.*}} @self_reference_1