1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // PR5392 4*f4a2713aSLionel Sambuc namespace PR5392 { 5*f4a2713aSLionel Sambuc struct A 6*f4a2713aSLionel Sambuc { 7*f4a2713aSLionel Sambuc static int a; 8*f4a2713aSLionel Sambuc }; 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc A a1; f()11*f4a2713aSLionel Sambucvoid f() 12*f4a2713aSLionel Sambuc { 13*f4a2713aSLionel Sambuc // CHECK: store i32 10, i32* @_ZN6PR53921A1aE 14*f4a2713aSLionel Sambuc a1.a = 10; 15*f4a2713aSLionel Sambuc // CHECK: store i32 20, i32* @_ZN6PR53921A1aE 16*f4a2713aSLionel Sambuc A().a = 20; 17*f4a2713aSLionel Sambuc } 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc } 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc struct A { 22*f4a2713aSLionel Sambuc A(); 23*f4a2713aSLionel Sambuc ~A(); 24*f4a2713aSLionel Sambuc enum E { Foo }; 25*f4a2713aSLionel Sambuc }; 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc A *g(); 28*f4a2713aSLionel Sambuc f(A * a)29*f4a2713aSLionel Sambucvoid f(A *a) { 30*f4a2713aSLionel Sambuc A::E e1 = a->Foo; 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc // CHECK: call %struct.A* @_Z1gv() 33*f4a2713aSLionel Sambuc A::E e2 = g()->Foo; 34*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AC1Ev( 35*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AD1Ev( 36*f4a2713aSLionel Sambuc A::E e3 = A().Foo; 37*f4a2713aSLionel Sambuc } 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc namespace test3 { 40*f4a2713aSLionel Sambuc struct A { 41*f4a2713aSLionel Sambuc static int foo(); 42*f4a2713aSLionel Sambuc }; f()43*f4a2713aSLionel Sambucint f() { 44*f4a2713aSLionel Sambuc return A().foo(); 45*f4a2713aSLionel Sambuc } 46*f4a2713aSLionel Sambuc } 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc namespace test4 { 49*f4a2713aSLionel Sambuc struct A { 50*f4a2713aSLionel Sambuc int x; 51*f4a2713aSLionel Sambuc }; 52*f4a2713aSLionel Sambuc struct B { 53*f4a2713aSLionel Sambuc int x; 54*f4a2713aSLionel Sambuc void foo(); 55*f4a2713aSLionel Sambuc }; 56*f4a2713aSLionel Sambuc struct C : A, B { 57*f4a2713aSLionel Sambuc }; 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc extern C *c_ptr; 60*f4a2713aSLionel Sambuc 61*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_ZN5test44testEv() test()62*f4a2713aSLionel Sambuc int test() { 63*f4a2713aSLionel Sambuc // CHECK: load {{.*}} @_ZN5test45c_ptrE 64*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 65*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr 66*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 67*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_ZN5test41B3fooEv 68*f4a2713aSLionel Sambuc c_ptr->B::foo(); 69*f4a2713aSLionel Sambuc 70*f4a2713aSLionel Sambuc // CHECK: load {{.*}} @_ZN5test45c_ptrE 71*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 72*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr 73*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 74*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr 75*f4a2713aSLionel Sambuc // CHECK-NEXT: store i32 5 76*f4a2713aSLionel Sambuc c_ptr->B::x = 5; 77*f4a2713aSLionel Sambuc 78*f4a2713aSLionel Sambuc // CHECK: load {{.*}} @_ZN5test45c_ptrE 79*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 80*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr 81*f4a2713aSLionel Sambuc // CHECK-NEXT: bitcast 82*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr 83*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* 84*f4a2713aSLionel Sambuc return c_ptr->B::x; 85*f4a2713aSLionel Sambuc } 86*f4a2713aSLionel Sambuc } 87