Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 %s -std=c++11 -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
      2 
      3 // PR10531.
      4 
      5 int make_a();
      6 
      7 static union {
      8   int a = make_a();
      9   char *b;
     10 };
     11 
     12 int f() { return a; }
     13 
     14 // CHECK-LABEL: define internal void @__cxx_global_var_init
     15 // CHECK-NOT: }
     16 // CHECK: call {{.*}}@"[[CONSTRUCT_GLOBAL:.*]]C1Ev"
     17 
     18 
     19 int g() {
     20   union {
     21     int a;
     22     int b = 81;
     23   };
     24   // CHECK-LABEL: define {{.*}}_Z1gv
     25   // CHECK-NOT: }
     26   // CHECK: call {{.*}}@"[[CONSTRUCT_LOCAL:.*]]C1Ev"
     27   return b;
     28 }
     29 
     30 struct A {
     31   A();
     32 };
     33 union B {
     34   int k;
     35   struct {
     36     A x;
     37     int y = 123;
     38   };
     39   B() {}
     40   B(int n) : k(n) {}
     41 };
     42 
     43 B b1;
     44 B b2(0);
     45 
     46 // CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev"
     47 // CHECK-NOT: }
     48 // CHECK: call {{.*}}@_Z6make_a
     49 
     50 // CHECK: define {{.*}}@"[[CONSTRUCT_LOCAL]]C2Ev"
     51 // CHECK-NOT: }
     52 // CHECK: store i32 81
     53 
     54 // CHECK-LABEL: define {{.*}} @_ZN1BC2Ev(
     55 // CHECK: call void @_ZN1AC1Ev(
     56 // CHECK: store i32 123,
     57 // CHECK: }
     58 
     59 // CHECK-LABEL: define {{.*}} @_ZN1BC2Ei(
     60 // CHECK-NOT: call void @_ZN1AC1Ev(
     61 // CHECK-NOT: store i32 123,
     62 // CHECK: store i32 %
     63 // CHECK-NOT: call void @_ZN1AC1Ev(
     64 // CHECK-NOT: store i32 123,
     65 // CHECK: }
     66