1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t 2*f4a2713aSLionel Sambuc // RUN: FileCheck %s -check-prefix=CHECK-1 < %t 3*f4a2713aSLionel Sambuc // RUN: FileCheck %s -check-prefix=CHECK-2 < %t 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc int f(); 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc namespace { 8*f4a2713aSLionel Sambuc // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 0 9*f4a2713aSLionel Sambuc // CHECK-1: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0 10*f4a2713aSLionel Sambuc // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0 11*f4a2713aSLionel Sambuc // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 0 12*f4a2713aSLionel Sambuc int a = 0; 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc int b = f(); 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc static int c = f(); 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc class D { 19*f4a2713aSLionel Sambuc static int d; 20*f4a2713aSLionel Sambuc }; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc int D::d = f(); 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc // Check for generation of a VTT with internal linkage 25*f4a2713aSLionel Sambuc // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant 26*f4a2713aSLionel Sambuc struct X { 27*f4a2713aSLionel Sambuc struct EBase { }; ~E__anon118d2d030111::X::E28*f4a2713aSLionel Sambuc struct E : public virtual EBase { virtual ~E() {} }; 29*f4a2713aSLionel Sambuc }; 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc // CHECK-1-LABEL: define internal i32 @_ZN12_GLOBAL__N_13fooEv() foo()32*f4a2713aSLionel Sambuc int foo() { 33*f4a2713aSLionel Sambuc return 32; 34*f4a2713aSLionel Sambuc } 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc // CHECK-1-LABEL: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() 37*f4a2713aSLionel Sambuc namespace A { foo()38*f4a2713aSLionel Sambuc int foo() { 39*f4a2713aSLionel Sambuc return 45; 40*f4a2713aSLionel Sambuc } 41*f4a2713aSLionel Sambuc } 42*f4a2713aSLionel Sambuc } 43*f4a2713aSLionel Sambuc concrete()44*f4a2713aSLionel Sambucint concrete() { 45*f4a2713aSLionel Sambuc return a + foo() + A::foo(); 46*f4a2713aSLionel Sambuc } 47*f4a2713aSLionel Sambuc test_XE()48*f4a2713aSLionel Sambucvoid test_XE() { throw X::E(); } 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // Miscompile on llvmc plugins. 51*f4a2713aSLionel Sambuc namespace test2 { 52*f4a2713aSLionel Sambuc struct A { 53*f4a2713aSLionel Sambuc template <class T> struct B { footest2::A::B54*f4a2713aSLionel Sambuc static void foo() {} 55*f4a2713aSLionel Sambuc }; 56*f4a2713aSLionel Sambuc }; 57*f4a2713aSLionel Sambuc namespace { 58*f4a2713aSLionel Sambuc struct C; 59*f4a2713aSLionel Sambuc } 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuc // CHECK-2-LABEL: define void @_ZN5test24testEv() 62*f4a2713aSLionel Sambuc // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() test()63*f4a2713aSLionel Sambuc void test() { 64*f4a2713aSLionel Sambuc A::B<C>::foo(); 65*f4a2713aSLionel Sambuc } 66*f4a2713aSLionel Sambuc 67*f4a2713aSLionel Sambuc // CHECK-2-LABEL: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() 68*f4a2713aSLionel Sambuc } 69*f4a2713aSLionel Sambuc 70*f4a2713aSLionel Sambuc namespace { 71*f4a2713aSLionel Sambuc bar()72*f4a2713aSLionel Sambucint bar() { 73*f4a2713aSLionel Sambuc extern int a; 74*f4a2713aSLionel Sambuc return a; 75*f4a2713aSLionel Sambuc } 76*f4a2713aSLionel Sambuc 77*f4a2713aSLionel Sambuc } // namespace 78