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