blob: acc77825ae847d95c6016a024c739d4bcff568ba [file] [log] [blame]
Richard Smith13ec9102012-05-14 21:57:21 +00001// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s
2
3struct A { int a, b; int f(); };
4
5// CHECK: define {{.*}}@_Z3fn1i(
6int fn1(int x) {
7 // CHECK: %[[INITLIST:.*]] = alloca %struct.A
8 // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 0
9 // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4
10 // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 1
11 // CHECK: store i32 5, i32* %[[B]], align 4
12 // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]])
13 return A{x, 5}.f();
14}
15
16struct B { int &r; int &f() { return r; } };
17
18// CHECK: define {{.*}}@_Z3fn2Ri(
19int &fn2(int &v) {
20 // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8
21 // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B* %[[INITLIST2:.*]], i32 0, i32 0
22 // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8
Richard Smith5dfced82012-05-14 22:06:02 +000023 // CHECK: call i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]])
Richard Smith13ec9102012-05-14 21:57:21 +000024 return B{v}.f();
25}