1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc struct A { 4*f4a2713aSLionel Sambuc int n = 0; 5*f4a2713aSLionel Sambuc const char *p; 6*f4a2713aSLionel Sambuc char k = p[n]; 7*f4a2713aSLionel Sambuc int f(); 8*f4a2713aSLionel Sambuc int x = f(); 9*f4a2713aSLionel Sambuc union { 10*f4a2713aSLionel Sambuc char c; 11*f4a2713aSLionel Sambuc double d = 1.0; 12*f4a2713aSLionel Sambuc }; 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc int f(); 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc union B { 18*f4a2713aSLionel Sambuc int a; 19*f4a2713aSLionel Sambuc int f(); 20*f4a2713aSLionel Sambuc int b = f(); 21*f4a2713aSLionel Sambuc }; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc A a { .p = "foobar" }; 24*f4a2713aSLionel Sambuc A b { 4, "bazquux", .x = 42, .c = 9 }; 25*f4a2713aSLionel Sambuc A c { 1, 0, 'A', f(), { 3 } }; 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc // CHECK: @[[STR_A:.*]] = {{.*}} [7 x i8] c"foobar\00" 28*f4a2713aSLionel Sambuc // CHECK: @a = global {{.*}} zeroinitializer 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc // @b has a constant initializer 31*f4a2713aSLionel Sambuc // CHECK: @[[STR_B:.*]] = {{.*}} [8 x i8] c"bazquux\00" 32*f4a2713aSLionel Sambuc // CHECK: @b = global {{.*}} i32 4, {{.*}} @[[STR_B]], {{.*}} i8 117, i32 42, {{.*}} i8 9 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc B x; 35*f4a2713aSLionel Sambuc B y {}; 36*f4a2713aSLionel Sambuc B z { 1 }; 37*f4a2713aSLionel Sambuc // CHECK: @z = global {{.*}} { i32 1 } 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc // Initialization of 'a': 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc // CHECK: store i32 0, i32* getelementptr inbounds ({{.*}} @a, i32 0, i32 0) 42*f4a2713aSLionel Sambuc // CHECK: store i8* {{.*}} @[[STR_A]]{{.*}}, i8** getelementptr inbounds ({{.*}} @a, i32 0, i32 1) 43*f4a2713aSLionel Sambuc // CHECK: load i32* getelementptr inbounds ({{.*}} @a, i32 0, i32 0) 44*f4a2713aSLionel Sambuc // CHECK: load i8** getelementptr inbounds ({{.*}} @a, i32 0, i32 1) 45*f4a2713aSLionel Sambuc // CHECK: getelementptr inbounds i8* %{{.*}}, {{.*}} %{{.*}} 46*f4a2713aSLionel Sambuc // CHECK: store i8 %{{.*}}, i8* getelementptr inbounds ({{.*}} @a, i32 0, i32 2) 47*f4a2713aSLionel Sambuc // CHECK: call i32 @_ZN1A1fEv({{.*}} @a) 48*f4a2713aSLionel Sambuc // CHECK: store i32 %{{.*}}, i32* getelementptr inbounds ({{.*}}* @a, i32 0, i32 3) 49*f4a2713aSLionel Sambuc // CHECK: call void @{{.*}}C1Ev({{.*}} getelementptr inbounds (%struct.A* @a, i32 0, i32 4)) 50*f4a2713aSLionel Sambuc 51*f4a2713aSLionel Sambuc // No dynamic initialization of 'b': 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambuc // CHECK-NOT: @b 54*f4a2713aSLionel Sambuc 55*f4a2713aSLionel Sambuc // Initialization of 'c': 56*f4a2713aSLionel Sambuc 57*f4a2713aSLionel Sambuc // CHECK: store i32 1, i32* getelementptr inbounds ({{.*}} @c, i32 0, i32 0) 58*f4a2713aSLionel Sambuc // CHECK: store i8* null, i8** getelementptr inbounds ({{.*}} @c, i32 0, i32 1) 59*f4a2713aSLionel Sambuc // CHECK-NOT: load 60*f4a2713aSLionel Sambuc // CHECK: store i8 65, i8* getelementptr inbounds ({{.*}} @c, i32 0, i32 2) 61*f4a2713aSLionel Sambuc // CHECK: call i32 @_Z1fv() 62*f4a2713aSLionel Sambuc // CHECK: store i32 %{{.*}}, i32* getelementptr inbounds ({{.*}}* @c, i32 0, i32 3) 63*f4a2713aSLionel Sambuc // CHECK-NOT: C1Ev 64*f4a2713aSLionel Sambuc // CHECK: store i8 3, i8* {{.*}} @c, i32 0, i32 4) 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC1Ev({{.*}} @x) 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc // CHECK: call i32 @_ZN1B1fEv({{.*}} @y) 69*f4a2713aSLionel Sambuc // CHECK: store i32 %{{.*}}, i32* getelementptr inbounds ({{.*}} @y, i32 0, i32 0) 70