Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -S -emit-llvm -o - %s -Wno-address-of-temporary | FileCheck %s |
Eli Friedman | c60ccf5 | 2012-02-29 00:00:28 +0000 | [diff] [blame] | 2 | |
Richard Smith | 0dbe2fb | 2012-12-21 03:17:28 +0000 | [diff] [blame] | 3 | // CHECK: @[[THREE_NULL_MEMPTRS:.*]] = private constant [3 x i32] [i32 -1, i32 -1, i32 -1] |
| 4 | |
Eli Friedman | c60ccf5 | 2012-02-29 00:00:28 +0000 | [diff] [blame] | 5 | struct A { int a[1]; }; |
| 6 | typedef A x[]; |
| 7 | int f() { |
| 8 | x{{{1}}}; |
| 9 | // CHECK: define i32 @_Z1fv |
| 10 | // CHECK: store i32 1 |
| 11 | // (It's okay if the output changes here, as long as we don't crash.) |
Richard Smith | 0dbe2fb | 2012-12-21 03:17:28 +0000 | [diff] [blame] | 12 | return 0; |
| 13 | } |
| 14 | |
| 15 | namespace ValueInitArrayOfMemPtr { |
| 16 | struct S {}; |
| 17 | typedef int (S::*p); |
| 18 | typedef p a[3]; |
| 19 | void f(const a &); |
| 20 | |
| 21 | struct Agg1 { |
| 22 | int n; |
| 23 | p x; |
| 24 | }; |
| 25 | |
| 26 | struct Agg2 { |
| 27 | int n; |
| 28 | a x; |
| 29 | }; |
| 30 | |
| 31 | struct S1 { |
| 32 | p x; |
| 33 | S1(); |
| 34 | }; |
| 35 | |
| 36 | // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1fEi |
| 37 | void f(int n) { |
| 38 | Agg1 a = { n }; |
| 39 | // CHECK: store i32 -1, |
| 40 | |
| 41 | Agg2 b = { n }; |
| 42 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false) |
| 43 | } |
| 44 | |
| 45 | // CHECK: define void @_ZN22ValueInitArrayOfMemPtr1gEv |
| 46 | void g() { |
| 47 | // CHECK: store i32 -1, |
| 48 | f(a{}); |
| 49 | } |
Eli Friedman | c60ccf5 | 2012-02-29 00:00:28 +0000 | [diff] [blame] | 50 | } |
Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 51 | |
| 52 | namespace array_dtor { |
| 53 | struct S { S(); ~S(); }; |
| 54 | using T = S[3]; |
| 55 | void f(const T &); |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 56 | void f(T *); |
Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 57 | // CHECK: define void @_ZN10array_dtor1gEv( |
| 58 | void g() { |
| 59 | // CHECK: %[[ARRAY:.*]] = alloca [3 x |
| 60 | // CHECK: br |
| 61 | |
| 62 | // Construct loop. |
| 63 | // CHECK: call void @_ZN10array_dtor1SC1Ev( |
| 64 | // CHECK: br i1 |
| 65 | |
| 66 | // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE( |
| 67 | // CHECK: br |
| 68 | |
| 69 | // Destruct loop. |
| 70 | // CHECK: call void @_ZN10array_dtor1SD1Ev( |
| 71 | // CHECK: br i1 |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 72 | f(T{}); |
Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 73 | |
| 74 | // CHECK: ret void |
Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 75 | } |
| 76 | // CHECK: define void @_ZN10array_dtor1hEv( |
| 77 | void h() { |
| 78 | // CHECK: %[[ARRAY:.*]] = alloca [3 x |
| 79 | // CHECK: br |
| 80 | |
| 81 | // CHECK: call void @_ZN10array_dtor1SC1Ev( |
| 82 | // CHECK: br i1 |
| 83 | T &&t = T{}; |
| 84 | |
| 85 | // CHECK: call void @_ZN10array_dtor1fERA3_KNS_1SE( |
| 86 | // CHECK: br |
| 87 | f(t); |
| 88 | |
| 89 | // CHECK: call void @_ZN10array_dtor1SD1Ev( |
| 90 | // CHECK: br i1 |
| 91 | |
| 92 | // CHECK: ret void |
| 93 | } |
Richard Smith | 3fa3fea | 2013-02-02 02:14:45 +0000 | [diff] [blame] | 94 | // CHECK: define void @_ZN10array_dtor1iEv( |
| 95 | void i() { |
| 96 | // CHECK: %[[ARRAY:.*]] = alloca [3 x |
| 97 | // CHECK: br |
| 98 | |
| 99 | // CHECK: call void @_ZN10array_dtor1SC1Ev( |
| 100 | // CHECK: br i1 |
| 101 | |
| 102 | // CHECK: call void @_ZN10array_dtor1fEPA3_NS_1SE( |
| 103 | // CHECK: br |
| 104 | |
| 105 | // CHECK: call void @_ZN10array_dtor1SD1Ev( |
| 106 | // CHECK: br i1 |
| 107 | f(&T{}); |
| 108 | |
| 109 | // CHECK: ret void |
| 110 | } |
Richard Smith | 802e226 | 2013-02-02 01:13:06 +0000 | [diff] [blame] | 111 | } |