xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/mangle-ms.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 -std=c++11 | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 -std=c++11| FileCheck -check-prefix X64 %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc int a;
5*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?a@@3HA"
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc namespace N {
8*f4a2713aSLionel Sambuc   int b;
9*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?b@N@@3HA"
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc   namespace {
12*f4a2713aSLionel Sambuc     int anonymous;
13*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?anonymous@?A@N@@3HA"
14*f4a2713aSLionel Sambuc   }
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc static int c;
18*f4a2713aSLionel Sambuc // CHECK-DAG: @c
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc int _c(void) {return N::anonymous + c;}
21*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?_c@@YAHXZ"
22*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?_c@@YAHXZ"
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc class foo {
25*f4a2713aSLionel Sambuc   static const short d;
26*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?d@foo@@0FB"
27*f4a2713aSLionel Sambuc protected:
28*f4a2713aSLionel Sambuc   static volatile long e;
29*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?e@foo@@1JC"
30*f4a2713aSLionel Sambuc public:
31*f4a2713aSLionel Sambuc   static const volatile char f;
32*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?f@foo@@2DD"
33*f4a2713aSLionel Sambuc   int operator+(int a);
34*f4a2713aSLionel Sambuc   foo(){}
35*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@XZ"
36*f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@XZ"
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc   ~foo(){}
39*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??1foo@@QAE@XZ"
40*f4a2713aSLionel Sambuc // X64-DAG:   @"\01??1foo@@QEAA@XZ
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc   foo(int i){}
43*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@H@Z"
44*f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@H@Z"
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc   foo(char *q){}
47*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@PAD@Z"
48*f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@PEAD@Z"
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc   static foo* static_method() { return 0; }
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc }f,s1(1),s2((char*)0);
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc typedef foo (foo2);
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc struct bar {
57*f4a2713aSLionel Sambuc   static int g;
58*f4a2713aSLionel Sambuc };
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc union baz {
61*f4a2713aSLionel Sambuc   int a;
62*f4a2713aSLionel Sambuc   char b;
63*f4a2713aSLionel Sambuc   double c;
64*f4a2713aSLionel Sambuc };
65*f4a2713aSLionel Sambuc 
66*f4a2713aSLionel Sambuc enum quux {
67*f4a2713aSLionel Sambuc   qone,
68*f4a2713aSLionel Sambuc   qtwo,
69*f4a2713aSLionel Sambuc   qthree
70*f4a2713aSLionel Sambuc };
71*f4a2713aSLionel Sambuc 
72*f4a2713aSLionel Sambuc foo bar() { return foo(); }
73*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?bar@@YA?AVfoo@@XZ"
74*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?bar@@YA?AVfoo@@XZ"
75*f4a2713aSLionel Sambuc 
76*f4a2713aSLionel Sambuc int foo::operator+(int a) {
77*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??Hfoo@@QAEHH@Z"
78*f4a2713aSLionel Sambuc // X64-DAG:   @"\01??Hfoo@@QEAAHH@Z"
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc   foo::static_method();
81*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?static_method@foo@@SAPAV1@XZ"
82*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?static_method@foo@@SAPEAV1@XZ"
83*f4a2713aSLionel Sambuc   bar();
84*f4a2713aSLionel Sambuc   return a;
85*f4a2713aSLionel Sambuc }
86*f4a2713aSLionel Sambuc 
87*f4a2713aSLionel Sambuc const short foo::d = 0;
88*f4a2713aSLionel Sambuc volatile long foo::e;
89*f4a2713aSLionel Sambuc const volatile char foo::f = 'C';
90*f4a2713aSLionel Sambuc 
91*f4a2713aSLionel Sambuc int bar::g;
92*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?g@bar@@2HA"
93*f4a2713aSLionel Sambuc 
94*f4a2713aSLionel Sambuc extern int * const h1 = &a;
95*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?h1@@3QAHA"
96*f4a2713aSLionel Sambuc extern const int * const h2 = &a;
97*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?h2@@3QBHB"
98*f4a2713aSLionel Sambuc 
99*f4a2713aSLionel Sambuc int i[10][20];
100*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?i@@3PAY0BE@HA"
101*f4a2713aSLionel Sambuc 
102*f4a2713aSLionel Sambuc int (__stdcall *j)(signed char, unsigned char);
103*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?j@@3P6GHCE@ZA"
104*f4a2713aSLionel Sambuc 
105*f4a2713aSLionel Sambuc const volatile char foo2::*k;
106*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?k@@3PTfoo@@DT1@"
107*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?k@@3PETfoo@@DET1@"
108*f4a2713aSLionel Sambuc 
109*f4a2713aSLionel Sambuc int (foo2::*l)(int);
110*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?l@@3P8foo@@AEHH@ZQ1@"
111*f4a2713aSLionel Sambuc 
112*f4a2713aSLionel Sambuc // Static functions are mangled, too.
113*f4a2713aSLionel Sambuc // Also make sure calling conventions, arglists, and throw specs work.
114*f4a2713aSLionel Sambuc static void __stdcall alpha(float a, double b) throw() {}
115*f4a2713aSLionel Sambuc bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
116*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?beta@@YI_N_J_W@Z"
117*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?beta@@YA_N_J_W@Z"
118*f4a2713aSLionel Sambuc   alpha(0.f, 0.0);
119*f4a2713aSLionel Sambuc   return false;
120*f4a2713aSLionel Sambuc }
121*f4a2713aSLionel Sambuc 
122*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?alpha@@YGXMN@Z"
123*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?alpha@@YAXMN@Z"
124*f4a2713aSLionel Sambuc 
125*f4a2713aSLionel Sambuc // Make sure tag-type mangling works.
126*f4a2713aSLionel Sambuc void gamma(class foo, struct bar, union baz, enum quux) {}
127*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
128*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
129*f4a2713aSLionel Sambuc 
130*f4a2713aSLionel Sambuc // Make sure pointer/reference-type mangling works.
131*f4a2713aSLionel Sambuc void delta(int * const a, const long &) {}
132*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?delta@@YAXQAHABJ@Z"
133*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?delta@@YAXQEAHAEBJ@Z"
134*f4a2713aSLionel Sambuc 
135*f4a2713aSLionel Sambuc // Array mangling.
136*f4a2713aSLionel Sambuc void epsilon(int a[][10][20]) {}
137*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?epsilon@@YAXQAY19BE@H@Z"
138*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?epsilon@@YAXQEAY19BE@H@Z"
139*f4a2713aSLionel Sambuc 
140*f4a2713aSLionel Sambuc void zeta(int (*)(int, int)) {}
141*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?zeta@@YAXP6AHHH@Z@Z"
142*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?zeta@@YAXP6AHHH@Z@Z"
143*f4a2713aSLionel Sambuc 
144*f4a2713aSLionel Sambuc // Blocks mangling (Clang extension). A block should be mangled slightly
145*f4a2713aSLionel Sambuc // differently from a similar function pointer.
146*f4a2713aSLionel Sambuc void eta(int (^)(int, int)) {}
147*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?eta@@YAXP_EAHHH@Z@Z"
148*f4a2713aSLionel Sambuc 
149*f4a2713aSLionel Sambuc typedef int theta_arg(int,int);
150*f4a2713aSLionel Sambuc void theta(theta_arg^ block) {}
151*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?theta@@YAXP_EAHHH@Z@Z"
152*f4a2713aSLionel Sambuc 
153*f4a2713aSLionel Sambuc void operator_new_delete() {
154*f4a2713aSLionel Sambuc   char *ptr = new char;
155*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??2@YAPAXI@Z"
156*f4a2713aSLionel Sambuc 
157*f4a2713aSLionel Sambuc   delete ptr;
158*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??3@YAXPAX@Z"
159*f4a2713aSLionel Sambuc 
160*f4a2713aSLionel Sambuc   char *array = new char[42];
161*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??_U@YAPAXI@Z"
162*f4a2713aSLionel Sambuc 
163*f4a2713aSLionel Sambuc   delete [] array;
164*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??_V@YAXPAX@Z"
165*f4a2713aSLionel Sambuc }
166*f4a2713aSLionel Sambuc 
167*f4a2713aSLionel Sambuc // PR13022
168*f4a2713aSLionel Sambuc void (redundant_parens)();
169*f4a2713aSLionel Sambuc void redundant_parens_use() { redundant_parens(); }
170*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?redundant_parens@@YAXXZ"
171*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?redundant_parens@@YAXXZ"
172*f4a2713aSLionel Sambuc 
173*f4a2713aSLionel Sambuc // PR13047
174*f4a2713aSLionel Sambuc typedef double RGB[3];
175*f4a2713aSLionel Sambuc RGB color1;
176*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color1@@3PANA"
177*f4a2713aSLionel Sambuc extern const RGB color2 = {};
178*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color2@@3QBNB"
179*f4a2713aSLionel Sambuc extern RGB const color3[5] = {};
180*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color3@@3QAY02$$CBNA"
181*f4a2713aSLionel Sambuc extern RGB const ((color4)[5]) = {};
182*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color4@@3QAY02$$CBNA"
183*f4a2713aSLionel Sambuc 
184*f4a2713aSLionel Sambuc struct B;
185*f4a2713aSLionel Sambuc volatile int B::* volatile memptr1;
186*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr1@@3RESB@@HES1@"
187*f4a2713aSLionel Sambuc volatile int B::* memptr2;
188*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr2@@3PESB@@HES1@"
189*f4a2713aSLionel Sambuc int B::* volatile memptr3;
190*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr3@@3REQB@@HEQ1@"
191*f4a2713aSLionel Sambuc typedef int (*fun)();
192*f4a2713aSLionel Sambuc volatile fun B::* volatile funmemptr1;
193*f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr1@@3RESB@@R6AHXZES1@"
194*f4a2713aSLionel Sambuc volatile fun B::* funmemptr2;
195*f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr2@@3PESB@@R6AHXZES1@"
196*f4a2713aSLionel Sambuc fun B::* volatile funmemptr3;
197*f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr3@@3REQB@@P6AHXZEQ1@"
198*f4a2713aSLionel Sambuc void (B::* volatile memptrtofun1)();
199*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun1@@3R8B@@EAAXXZEQ1@"
200*f4a2713aSLionel Sambuc const void (B::* memptrtofun2)();
201*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun2@@3P8B@@EAAXXZEQ1@"
202*f4a2713aSLionel Sambuc volatile void (B::* memptrtofun3)();
203*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun3@@3P8B@@EAAXXZEQ1@"
204*f4a2713aSLionel Sambuc int (B::* volatile memptrtofun4)();
205*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun4@@3R8B@@EAAHXZEQ1@"
206*f4a2713aSLionel Sambuc volatile int (B::* memptrtofun5)();
207*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun5@@3P8B@@EAA?CHXZEQ1@"
208*f4a2713aSLionel Sambuc const int (B::* memptrtofun6)();
209*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun6@@3P8B@@EAA?BHXZEQ1@"
210*f4a2713aSLionel Sambuc fun (B::* volatile memptrtofun7)();
211*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun7@@3R8B@@EAAP6AHXZXZEQ1@"
212*f4a2713aSLionel Sambuc volatile fun (B::* memptrtofun8)();
213*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun8@@3P8B@@EAAR6AHXZXZEQ1@"
214*f4a2713aSLionel Sambuc const fun (B::* memptrtofun9)();
215*f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun9@@3P8B@@EAAQ6AHXZXZEQ1@"
216*f4a2713aSLionel Sambuc 
217*f4a2713aSLionel Sambuc // PR12603
218*f4a2713aSLionel Sambuc enum E {};
219*f4a2713aSLionel Sambuc // CHECK-DAG: "\01?fooE@@YA?AW4E@@XZ"
220*f4a2713aSLionel Sambuc // X64-DAG:   "\01?fooE@@YA?AW4E@@XZ"
221*f4a2713aSLionel Sambuc E fooE() { return E(); }
222*f4a2713aSLionel Sambuc 
223*f4a2713aSLionel Sambuc class X {};
224*f4a2713aSLionel Sambuc // CHECK-DAG: "\01?fooX@@YA?AVX@@XZ"
225*f4a2713aSLionel Sambuc // X64-DAG:   "\01?fooX@@YA?AVX@@XZ"
226*f4a2713aSLionel Sambuc X fooX() { return X(); }
227*f4a2713aSLionel Sambuc 
228*f4a2713aSLionel Sambuc namespace PR13182 {
229*f4a2713aSLionel Sambuc   extern char s0[];
230*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s0@PR13182@@3PADA"
231*f4a2713aSLionel Sambuc   extern char s1[42];
232*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s1@PR13182@@3PADA"
233*f4a2713aSLionel Sambuc   extern const char s2[];
234*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s2@PR13182@@3QBDB"
235*f4a2713aSLionel Sambuc   extern const char s3[42];
236*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s3@PR13182@@3QBDB"
237*f4a2713aSLionel Sambuc   extern volatile char s4[];
238*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s4@PR13182@@3RCDC"
239*f4a2713aSLionel Sambuc   extern const volatile char s5[];
240*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s5@PR13182@@3SDDD"
241*f4a2713aSLionel Sambuc   extern const char* const* s6;
242*f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s6@PR13182@@3PBQBDB"
243*f4a2713aSLionel Sambuc 
244*f4a2713aSLionel Sambuc   char foo() {
245*f4a2713aSLionel Sambuc     return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
246*f4a2713aSLionel Sambuc   }
247*f4a2713aSLionel Sambuc }
248*f4a2713aSLionel Sambuc 
249*f4a2713aSLionel Sambuc extern "C" inline void extern_c_func() {
250*f4a2713aSLionel Sambuc   static int local;
251*f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?local@?1??extern_c_func@@9@4HA"
252*f4a2713aSLionel Sambuc // X64-DAG:   @"\01?local@?1??extern_c_func@@9@4HA"
253*f4a2713aSLionel Sambuc }
254*f4a2713aSLionel Sambuc 
255*f4a2713aSLionel Sambuc void call_extern_c_func() {
256*f4a2713aSLionel Sambuc   extern_c_func();
257*f4a2713aSLionel Sambuc }
258*f4a2713aSLionel Sambuc 
259*f4a2713aSLionel Sambuc int main() { return 0; }
260*f4a2713aSLionel Sambuc // CHECK-DAG: @main
261*f4a2713aSLionel Sambuc // X64-DAG:   @main
262*f4a2713aSLionel Sambuc 
263*f4a2713aSLionel Sambuc int wmain() { return 0; }
264*f4a2713aSLionel Sambuc // CHECK-DAG: @wmain
265*f4a2713aSLionel Sambuc // X64-DAG:   @wmain
266*f4a2713aSLionel Sambuc 
267*f4a2713aSLionel Sambuc int WinMain() { return 0; }
268*f4a2713aSLionel Sambuc // CHECK-DAG: @WinMain
269*f4a2713aSLionel Sambuc // X64-DAG:   @WinMain
270*f4a2713aSLionel Sambuc 
271*f4a2713aSLionel Sambuc int wWinMain() { return 0; }
272*f4a2713aSLionel Sambuc // CHECK-DAG: @wWinMain
273*f4a2713aSLionel Sambuc // X64-DAG:   @wWinMain
274*f4a2713aSLionel Sambuc 
275*f4a2713aSLionel Sambuc int DllMain() { return 0; }
276*f4a2713aSLionel Sambuc // CHECK-DAG: @DllMain
277*f4a2713aSLionel Sambuc // X64-DAG:   @DllMain
278*f4a2713aSLionel Sambuc 
279*f4a2713aSLionel Sambuc inline int inline_function_with_local_type() {
280*f4a2713aSLionel Sambuc   static struct {
281*f4a2713aSLionel Sambuc     int a_field;
282*f4a2713aSLionel Sambuc   } static_variable_in_inline_function = { 20 }, second_static = { 40 };
283*f4a2713aSLionel Sambuc   // CHECK: @"\01?static_variable_in_inline_function@?1??inline_function_with_local_type@@YAHXZ@4U<unnamed-type-static_variable_in_inline_function>@?1??1@YAHXZ@A"
284*f4a2713aSLionel Sambuc 
285*f4a2713aSLionel Sambuc   return static_variable_in_inline_function.a_field + second_static.a_field;
286*f4a2713aSLionel Sambuc }
287*f4a2713aSLionel Sambuc 
288*f4a2713aSLionel Sambuc int call_inline_function_with_local_type() {
289*f4a2713aSLionel Sambuc   return inline_function_with_local_type();
290*f4a2713aSLionel Sambuc }
291*f4a2713aSLionel Sambuc 
292*f4a2713aSLionel Sambuc template <typename T>
293*f4a2713aSLionel Sambuc inline int templated_inline_function_with_local_type() {
294*f4a2713aSLionel Sambuc   static struct {
295*f4a2713aSLionel Sambuc     int a_field;
296*f4a2713aSLionel Sambuc   } static_variable_in_templated_inline_function = { 20 },
297*f4a2713aSLionel Sambuc     second_static = { 40 };
298*f4a2713aSLionel Sambuc   // CHECK: @"\01?static_variable_in_templated_inline_function@?1???$templated_inline_function_with_local_type@H@@YAHXZ@4U<unnamed-type-static_variable_in_templated_inline_function>@?1???$templated_inline_function_with_local_type@H@@YAHXZ@A"
299*f4a2713aSLionel Sambuc 
300*f4a2713aSLionel Sambuc   return static_variable_in_templated_inline_function.a_field +
301*f4a2713aSLionel Sambuc          second_static.a_field;
302*f4a2713aSLionel Sambuc }
303*f4a2713aSLionel Sambuc 
304*f4a2713aSLionel Sambuc int call_templated_inline_function_with_local_type() {
305*f4a2713aSLionel Sambuc   return templated_inline_function_with_local_type<int>();
306*f4a2713aSLionel Sambuc }
307*f4a2713aSLionel Sambuc 
308*f4a2713aSLionel Sambuc // PR17371
309*f4a2713aSLionel Sambuc struct OverloadedNewDelete {
310*f4a2713aSLionel Sambuc   // __cdecl
311*f4a2713aSLionel Sambuc   void *operator new(__SIZE_TYPE__);
312*f4a2713aSLionel Sambuc   void *operator new[](__SIZE_TYPE__);
313*f4a2713aSLionel Sambuc   void operator delete(void *);
314*f4a2713aSLionel Sambuc   void operator delete[](void *);
315*f4a2713aSLionel Sambuc   // __thiscall
316*f4a2713aSLionel Sambuc   int operator+(int);
317*f4a2713aSLionel Sambuc };
318*f4a2713aSLionel Sambuc 
319*f4a2713aSLionel Sambuc void *OverloadedNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
320*f4a2713aSLionel Sambuc void *OverloadedNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
321*f4a2713aSLionel Sambuc void OverloadedNewDelete::operator delete(void *) { }
322*f4a2713aSLionel Sambuc void OverloadedNewDelete::operator delete[](void *) { }
323*f4a2713aSLionel Sambuc int OverloadedNewDelete::operator+(int x) { return x; };
324*f4a2713aSLionel Sambuc 
325*f4a2713aSLionel Sambuc // CHECK-DAG: ??2OverloadedNewDelete@@SAPAXI@Z
326*f4a2713aSLionel Sambuc // CHECK-DAG: ??_UOverloadedNewDelete@@SAPAXI@Z
327*f4a2713aSLionel Sambuc // CHECK-DAG: ??3OverloadedNewDelete@@SAXPAX@Z
328*f4a2713aSLionel Sambuc // CHECK-DAG: ??_VOverloadedNewDelete@@SAXPAX@Z
329*f4a2713aSLionel Sambuc // CHECK-DAG: ??HOverloadedNewDelete@@QAEHH@Z
330*f4a2713aSLionel Sambuc 
331*f4a2713aSLionel Sambuc // X64-DAG:   ??2OverloadedNewDelete@@SAPEAX_K@Z
332*f4a2713aSLionel Sambuc // X64-DAG:   ??_UOverloadedNewDelete@@SAPEAX_K@Z
333*f4a2713aSLionel Sambuc // X64-DAG:   ??3OverloadedNewDelete@@SAXPEAX@Z
334*f4a2713aSLionel Sambuc // X64-DAG:   ??_VOverloadedNewDelete@@SAXPEAX@Z
335*f4a2713aSLionel Sambuc // X64-DAG:   ??HOverloadedNewDelete@@QEAAHH@Z
336*f4a2713aSLionel Sambuc 
337*f4a2713aSLionel Sambuc // Indirecting the function type through a typedef will require a calling
338*f4a2713aSLionel Sambuc // convention adjustment before building the method decl.
339*f4a2713aSLionel Sambuc 
340*f4a2713aSLionel Sambuc typedef void *__thiscall OperatorNewType(__SIZE_TYPE__);
341*f4a2713aSLionel Sambuc typedef void __thiscall OperatorDeleteType(void *);
342*f4a2713aSLionel Sambuc 
343*f4a2713aSLionel Sambuc struct TypedefNewDelete {
344*f4a2713aSLionel Sambuc   OperatorNewType operator new;
345*f4a2713aSLionel Sambuc   OperatorNewType operator new[];
346*f4a2713aSLionel Sambuc   OperatorDeleteType operator delete;
347*f4a2713aSLionel Sambuc   OperatorDeleteType operator delete[];
348*f4a2713aSLionel Sambuc };
349*f4a2713aSLionel Sambuc 
350*f4a2713aSLionel Sambuc void *TypedefNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
351*f4a2713aSLionel Sambuc void *TypedefNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
352*f4a2713aSLionel Sambuc void TypedefNewDelete::operator delete(void *) { }
353*f4a2713aSLionel Sambuc void TypedefNewDelete::operator delete[](void *) { }
354*f4a2713aSLionel Sambuc 
355*f4a2713aSLionel Sambuc // CHECK-DAG: ??2TypedefNewDelete@@SAPAXI@Z
356*f4a2713aSLionel Sambuc // CHECK-DAG: ??_UTypedefNewDelete@@SAPAXI@Z
357*f4a2713aSLionel Sambuc // CHECK-DAG: ??3TypedefNewDelete@@SAXPAX@Z
358*f4a2713aSLionel Sambuc // CHECK-DAG: ??_VTypedefNewDelete@@SAXPAX@Z
359*f4a2713aSLionel Sambuc 
360*f4a2713aSLionel Sambuc namespace PR18022 {
361*f4a2713aSLionel Sambuc 
362*f4a2713aSLionel Sambuc struct { } a;
363*f4a2713aSLionel Sambuc decltype(a) fun(decltype(a) x, decltype(a)) { return x; }
364*f4a2713aSLionel Sambuc // CHECK-DAG: ?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z
365*f4a2713aSLionel Sambuc 
366*f4a2713aSLionel Sambuc }
367