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