1 // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
2 
3 // CHECK: @"\01?a@@3HA"
4 // CHECK: @"\01?b@N@@3HA"
5 // CHECK: @c
6 // CHECK: @"\01?d@foo@@0FB"
7 // CHECK: @"\01?e@foo@@1JC"
8 // CHECK: @"\01?f@foo@@2DD"
9 // CHECK: @"\01?g@bar@@2HA"
10 // CHECK: @"\01?h@@3QAHA"
11 // CHECK: @"\01?i@@3PAY0BE@HA"
12 // CHECK: @"\01?j@@3P6GHCE@ZA"
13 // CHECK: @"\01?k@@3PTfoo@@DA"
14 // CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
15 // CHECK: @"\01?color1@@3PANA"
16 // CHECK: @"\01?color2@@3PBNA"
17 // CHECK: @"\01?color3@@3PBY02NA"
18 
19 int a;
20 
21 namespace N { int b; }
22 
23 static int c;
24 int _c(void) {return c;}
25 // CHECK: @"\01?_c@@YAHXZ"
26 
27 class foo {
28   static const short d;
29 protected:
30   static volatile long e;
31 public:
32   static const volatile char f;
33   int operator+(int a);
34   foo(){}
35 //CHECK: @"\01??0foo@@QAE@XZ"
36 
37   ~foo(){}
38 //CHECK: @"\01??1foo@@QAE@XZ"
39 
40   foo(int i){}
41 //CHECK: @"\01??0foo@@QAE@H@Z"
42 
43   foo(char *q){}
44 //CHECK: @"\01??0foo@@QAE@PAD@Z"
45 
46   static foo* static_method() { return 0; }
47 
48 }f,s1(1),s2((char*)0);
49 
50 typedef foo (foo2);
51 
52 struct bar {
53   static int g;
54 };
55 
56 union baz {
57   int a;
58   char b;
59   double c;
60 };
61 
62 enum quux {
63   qone,
64   qtwo,
65   qthree
66 };
67 
68 foo bar() { return foo(); }
69 //CHECK: @"\01?bar@@YA?AVfoo@@XZ"
70 
71 int foo::operator+(int a) {
72 //CHECK: @"\01??Hfoo@@QAEHH@Z"
73 
74   foo::static_method();
75 //CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
76   bar();
77   return a;
78 }
79 
80 const short foo::d = 0;
81 volatile long foo::e;
82 const volatile char foo::f = 'C';
83 
84 int bar::g;
85 
86 extern int * const h = &a;
87 
88 int i[10][20];
89 
90 int (__stdcall *j)(signed char, unsigned char);
91 
92 const volatile char foo2::*k;
93 
94 int (foo2::*l)(int);
95 
96 // Static functions are mangled, too.
97 // Also make sure calling conventions, arglists, and throw specs work.
98 static void __stdcall alpha(float a, double b) throw() {}
99 bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
100 // CHECK: @"\01?beta@@YI_N_J_W@Z"
101   alpha(0.f, 0.0);
102   return false;
103 }
104 
105 // CHECK: @"\01?alpha@@YGXMN@Z"
106 
107 // Make sure tag-type mangling works.
108 void gamma(class foo, struct bar, union baz, enum quux) {}
109 // CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
110 
111 // Make sure pointer/reference-type mangling works.
112 void delta(int * const a, const long &) {}
113 // CHECK: @"\01?delta@@YAXQAHABJ@Z"
114 
115 // Array mangling.
116 void epsilon(int a[][10][20]) {}
117 // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
118 
119 // Blocks mangling (Clang extension).
120 void zeta(int (^)(int, int)) {}
121 // CHECK: @"\01?zeta@@YAXP_EAHHH@Z@Z"
122 
123 void operator_new_delete() {
124   char *ptr = new char;
125 // CHECK: @"\01??2@YAPAXI@Z"
126 
127   delete ptr;
128 // CHECK: @"\01??3@YAXPAX@Z"
129 
130   char *array = new char[42];
131 // CHECK: @"\01??_U@YAPAXI@Z"
132 
133   delete [] array;
134 // CHECK: @"\01??_V@YAXPAX@Z"
135 }
136 
137 // PR13022
138 void (redundant_parens)();
139 void redundant_parens_use() { redundant_parens(); }
140 // CHECK: @"\01?redundant_parens@@YAXXZ"
141 
142 // PR13047
143 typedef double RGB[3];
144 RGB color1;
145 extern const RGB color2 = {};
146 extern RGB const ((color3)[5]) = {};
147 
148 // PR12603
149 enum E {};
150 // CHECK: "\01?fooE@@YA?AW4E@@XZ"
151 E fooE() { return E(); }
152 
153 class X {};
154 // CHECK: "\01?fooX@@YA?AVX@@XZ"
155 X fooX() { return X(); }
156