Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O2 -emit-llvm -o - | FileCheck %s
      2 // PR11480
      3 
      4 void foo(int);
      5 
      6 class A {
      7 public:
      8   A() { foo(1); }
      9 };
     10 
     11 class A1 {
     12 public:
     13   A1() { foo(2); }
     14 };
     15 
     16 class B {
     17 public:
     18   B() { foo(3); }
     19 };
     20 
     21 class C {
     22 public:
     23   static A a;
     24   C() { foo(4); }
     25 };
     26 
     27 
     28 A C::a = A();
     29 
     30 // CHECK: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }]
     31 // CHECK: [{ i32, void ()*, i8* } { i32 200, void ()* @_GLOBAL__I_000200, i8* null },
     32 // CHECK:  { i32, void ()*, i8* } { i32 300, void ()* @_GLOBAL__I_000300, i8* null },
     33 // CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_init_priority_attr.cpp, i8* null }]
     34 
     35 // CHECK: _GLOBAL__I_000200()
     36 // CHECK: _Z3fooi(i32 3)
     37 // CHECK-NEXT: ret void
     38 
     39 // CHECK: _GLOBAL__I_000300()
     40 // CHECK: _Z3fooi(i32 2)
     41 // CHECK-NEXT: _Z3fooi(i32 1)
     42 // CHECK-NEXT: ret void
     43 
     44 // CHECK: _GLOBAL__sub_I_init_priority_attr.cpp()
     45 // CHECK: _Z3fooi(i32 1)
     46 // CHECK-NEXT: _Z3fooi(i32 4)
     47 // CHECK-NEXT: ret void
     48 
     49 C c;
     50 A1 a1 __attribute__((init_priority (300)));
     51 A a __attribute__((init_priority (300)));
     52 B b __attribute__((init_priority (200)));
     53