aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-05-14 21:57:21 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-05-14 21:57:21 +0000
commit13ec9100ca6bc03b5ce8832e4a0fcb724d47bcb1 (patch)
tree85a33f60442dc1bf692f12a2669d62b10cc9efcb /test/CodeGenCXX/cxx11-initializer-aggregate.cpp
parent2ba542c741c39691940f5d1de0bc88c22f46c430 (diff)
Implement IRGen for C++11's "T{1, 2, 3}", where T is an aggregate and the
expression is treated as an lvalue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/cxx11-initializer-aggregate.cpp')
-rw-r--r--test/CodeGenCXX/cxx11-initializer-aggregate.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
new file mode 100644
index 0000000000..f96638184e
--- /dev/null
+++ b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
+
+struct A { int a, b; int f(); };
+
+// CHECK: define {{.*}}@_Z3fn1i(
+int fn1(int x) {
+ // CHECK: %[[INITLIST:.*]] = alloca %struct.A
+ // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 0
+ // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4
+ // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 1
+ // CHECK: store i32 5, i32* %[[B]], align 4
+ // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]])
+ return A{x, 5}.f();
+}
+
+struct B { int &r; int &f() { return r; } };
+
+// CHECK: define {{.*}}@_Z3fn2Ri(
+int &fn2(int &v) {
+ // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8
+ // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B* %[[INITLIST2:.*]], i32 0, i32 0
+ // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8
+ // CHECK: %call = call i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]])
+ return B{v}.f();
+}