1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc struct S { ~SS4*f4a2713aSLionel Sambuc virtual ~S() { } 5*f4a2713aSLionel Sambuc }; 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc // PR5706 8*f4a2713aSLionel Sambuc // Make sure this doesn't crash; the mangling doesn't matter because the name 9*f4a2713aSLionel Sambuc // doesn't have linkage. 10*f4a2713aSLionel Sambuc static struct : S { } obj8; 11*f4a2713aSLionel Sambuc f()12*f4a2713aSLionel Sambucvoid f() { 13*f4a2713aSLionel Sambuc // Make sure this doesn't crash; the mangling doesn't matter because the 14*f4a2713aSLionel Sambuc // generated vtable/etc. aren't modifiable (although it would be nice for 15*f4a2713aSLionel Sambuc // codesize to make it consistent inside inline functions). 16*f4a2713aSLionel Sambuc static struct : S { } obj8; 17*f4a2713aSLionel Sambuc } 18*f4a2713aSLionel Sambuc f2()19*f4a2713aSLionel Sambucinline int f2() { 20*f4a2713aSLionel Sambuc // FIXME: We don't mangle the names of a or x correctly! 21*f4a2713aSLionel Sambuc static struct { int a() { static int x; return ++x; } } obj; 22*f4a2713aSLionel Sambuc return obj.a(); 23*f4a2713aSLionel Sambuc } 24*f4a2713aSLionel Sambuc f3()25*f4a2713aSLionel Sambucint f3() { return f2(); } 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc struct A { 28*f4a2713aSLionel Sambuc typedef struct { int x; } *ptr; 29*f4a2713aSLionel Sambuc ptr m; aA30*f4a2713aSLionel Sambuc int a() { 31*f4a2713aSLionel Sambuc static struct x { 32*f4a2713aSLionel Sambuc // FIXME: We don't mangle the names of a or x correctly! 33*f4a2713aSLionel Sambuc int a(ptr A::*memp) { static int x; return ++x; } 34*f4a2713aSLionel Sambuc } a; 35*f4a2713aSLionel Sambuc return a.a(&A::m); 36*f4a2713aSLionel Sambuc } 37*f4a2713aSLionel Sambuc }; 38*f4a2713aSLionel Sambuc f4()39*f4a2713aSLionel Sambucint f4() { return A().a(); } 40*f4a2713aSLionel Sambuc f5()41*f4a2713aSLionel Sambucint f5() { 42*f4a2713aSLionel Sambuc static union { 43*f4a2713aSLionel Sambuc int a; 44*f4a2713aSLionel Sambuc }; 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc // CHECK: _ZZ2f5vE1a 47*f4a2713aSLionel Sambuc return a; 48*f4a2713aSLionel Sambuc } 49*f4a2713aSLionel Sambuc f6()50*f4a2713aSLionel Sambucint f6() { 51*f4a2713aSLionel Sambuc static union { 52*f4a2713aSLionel Sambuc union { 53*f4a2713aSLionel Sambuc int : 1; 54*f4a2713aSLionel Sambuc }; 55*f4a2713aSLionel Sambuc int b; 56*f4a2713aSLionel Sambuc }; 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc // CHECK: _ZZ2f6vE1b 59*f4a2713aSLionel Sambuc return b; 60*f4a2713aSLionel Sambuc } 61*f4a2713aSLionel Sambuc f7()62*f4a2713aSLionel Sambucint f7() { 63*f4a2713aSLionel Sambuc static union { 64*f4a2713aSLionel Sambuc union { 65*f4a2713aSLionel Sambuc int b; 66*f4a2713aSLionel Sambuc } a; 67*f4a2713aSLionel Sambuc }; 68*f4a2713aSLionel Sambuc 69*f4a2713aSLionel Sambuc // CHECK: _ZZ2f7vE1a 70*f4a2713aSLionel Sambuc return a.b; 71*f4a2713aSLionel Sambuc } 72*f4a2713aSLionel Sambuc 73*f4a2713aSLionel Sambuc // This used to cause an assert because the typedef-for-anonymous-tag 74*f4a2713aSLionel Sambuc // code was trying to claim the enum for the template. 75*f4a2713aSLionel Sambuc enum { T8 }; 76*f4a2713aSLionel Sambuc template <class T> struct Test8 { 77*f4a2713aSLionel Sambuc typedef T type; Test8Test878*f4a2713aSLionel Sambuc Test8(type t) {} // tested later 79*f4a2713aSLionel Sambuc }; make_test8(T value)80*f4a2713aSLionel Sambuctemplate <class T> void make_test8(T value) { Test8<T> t(value); } test8()81*f4a2713aSLionel Sambucvoid test8() { make_test8(T8); } 82*f4a2713aSLionel Sambuc 83*f4a2713aSLionel Sambuc // CHECK-LABEL: define internal void @"_ZNV3$_35test9Ev"( 84*f4a2713aSLionel Sambuc typedef volatile struct { test9__anon54f453f60b0885*f4a2713aSLionel Sambuc void test9() volatile {} 86*f4a2713aSLionel Sambuc } Test9; test9()87*f4a2713aSLionel Sambucvoid test9() { 88*f4a2713aSLionel Sambuc Test9 a; 89*f4a2713aSLionel Sambuc a.test9(); 90*f4a2713aSLionel Sambuc } 91*f4a2713aSLionel Sambuc 92*f4a2713aSLionel Sambuc // CHECK-LABEL: define internal void @"_ZN5Test8I3$_2EC1ES0_"( 93