xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/mangle.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -fblocks -std=c++11 | FileCheck %s
2f4a2713aSLionel Sambuc struct X { };
3f4a2713aSLionel Sambuc struct Y { };
4f4a2713aSLionel Sambuc 
5f4a2713aSLionel Sambuc // CHECK: @unmangled_variable = global
6f4a2713aSLionel Sambuc // CHECK: @_ZN1N1iE = global
7f4a2713aSLionel Sambuc // CHECK: @_ZZN1N1fEiiE1b = internal global
8f4a2713aSLionel Sambuc // CHECK: @_ZZN1N1gEvE1a = internal global
9f4a2713aSLionel Sambuc // CHECK: @_ZGVZN1N1gEvE1a = internal global
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc //CHECK: @pr5966_i = external global
12f4a2713aSLionel Sambuc //CHECK: @_ZL8pr5966_j = internal global
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc // CHECK-LABEL: define zeroext i1 @_ZplRK1YRA100_P1X
operator +(const Y &,X * (& xs)[100])15f4a2713aSLionel Sambuc bool operator+(const Y&, X* (&xs)[100]) { return false; }
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f1s
18f4a2713aSLionel Sambuc typedef struct { int a; } s;
f(s)19f4a2713aSLionel Sambuc void f(s) { }
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f1e
22f4a2713aSLionel Sambuc typedef enum { foo } e;
f(e)23f4a2713aSLionel Sambuc void f(e) { }
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f1u
26f4a2713aSLionel Sambuc typedef union { int a; } u;
f(u)27f4a2713aSLionel Sambuc void f(u) { }
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f1x
30f4a2713aSLionel Sambuc typedef struct { int a; } x,y;
f(y)31f4a2713aSLionel Sambuc void f(y) { }
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fv
f()34f4a2713aSLionel Sambuc void f() { }
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1N1fEv
f()37f4a2713aSLionel Sambuc namespace N { void f() { } }
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN1N1N1fEv
f()40f4a2713aSLionel Sambuc namespace N { namespace N { void f() { } } }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc // CHECK-LABEL: define void @unmangled_function
unmangled_function()43f4a2713aSLionel Sambuc extern "C" { namespace N { void unmangled_function() { } } }
44f4a2713aSLionel Sambuc 
45f4a2713aSLionel Sambuc extern "C" { namespace N { int unmangled_variable = 10; } }
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc namespace N { int i; }
48f4a2713aSLionel Sambuc 
f(int,int)49f4a2713aSLionel Sambuc namespace N { int f(int, int) { static int b; return b; } }
50f4a2713aSLionel Sambuc 
g()51f4a2713aSLionel Sambuc namespace N { int h(); void g() { static int a = h(); } }
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fno
f(__int128_t,__uint128_t)54f4a2713aSLionel Sambuc void f(__int128_t, __uint128_t) { }
55f4a2713aSLionel Sambuc 
56f4a2713aSLionel Sambuc template <typename T> struct S1 {};
57f4a2713aSLionel Sambuc 
58f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S1IiE
f(S1<int>)59f4a2713aSLionel Sambuc void f(S1<int>) {}
60f4a2713aSLionel Sambuc 
61f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S1IdE
f(S1<double>)62f4a2713aSLionel Sambuc void f(S1<double>) {}
63f4a2713aSLionel Sambuc 
64f4a2713aSLionel Sambuc template <int N> struct S2 {};
65f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S2ILi100EE
f(S2<100>)66f4a2713aSLionel Sambuc void f(S2<100>) {}
67f4a2713aSLionel Sambuc 
68f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S2ILin100EE
f(S2<-100>)69f4a2713aSLionel Sambuc void f(S2<-100>) {}
70f4a2713aSLionel Sambuc 
71f4a2713aSLionel Sambuc template <bool B> struct S3 {};
72f4a2713aSLionel Sambuc 
73f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S3ILb1EE
f(S3<true>)74f4a2713aSLionel Sambuc void f(S3<true>) {}
75f4a2713aSLionel Sambuc 
76f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1f2S3ILb0EE
f(S3<false>)77f4a2713aSLionel Sambuc void f(S3<false>) {}
78f4a2713aSLionel Sambuc 
79f4a2713aSLionel Sambuc struct S;
80f4a2713aSLionel Sambuc 
81f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fM1SKFvvE
f(void (S::*)()const)82f4a2713aSLionel Sambuc void f(void (S::*)() const) {}
83f4a2713aSLionel Sambuc 
84f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fM1SFvvE
f(void (S::*)())85f4a2713aSLionel Sambuc void f(void (S::*)()) {}
86f4a2713aSLionel Sambuc 
87f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fi
f(const int)88f4a2713aSLionel Sambuc void f(const int) { }
89f4a2713aSLionel Sambuc 
ft1(U u,T t)90f4a2713aSLionel Sambuc template<typename T, typename U> void ft1(U u, T t) { }
91f4a2713aSLionel Sambuc 
ft2(T t,void (*)(T),void (*)(T))92f4a2713aSLionel Sambuc template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
93f4a2713aSLionel Sambuc 
94f4a2713aSLionel Sambuc template<typename T, typename U = S1<T> > struct S4 { };
ft3(S4<T> *)95f4a2713aSLionel Sambuc template<typename T> void ft3(S4<T>*) {  }
96f4a2713aSLionel Sambuc 
97f4a2713aSLionel Sambuc namespace NS {
ft1(T)98f4a2713aSLionel Sambuc   template<typename T> void ft1(T) { }
99f4a2713aSLionel Sambuc }
100f4a2713aSLionel Sambuc 
g1()101f4a2713aSLionel Sambuc void g1() {
102f4a2713aSLionel Sambuc   // CHECK: @_Z3ft1IidEvT0_T_
103f4a2713aSLionel Sambuc   ft1<int, double>(1, 0);
104f4a2713aSLionel Sambuc 
105f4a2713aSLionel Sambuc   // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
106f4a2713aSLionel Sambuc   ft2<char>(1, 0, 0);
107f4a2713aSLionel Sambuc 
108f4a2713aSLionel Sambuc   // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
109f4a2713aSLionel Sambuc   ft3<int>(0);
110f4a2713aSLionel Sambuc 
111f4a2713aSLionel Sambuc   // CHECK: @_ZN2NS3ft1IiEEvT_
112f4a2713aSLionel Sambuc   NS::ft1<int>(1);
113f4a2713aSLionel Sambuc }
114f4a2713aSLionel Sambuc 
115f4a2713aSLionel Sambuc // Expressions
116f4a2713aSLionel Sambuc template<int I> struct S5 { };
117f4a2713aSLionel Sambuc 
ft4(S5<I>)118f4a2713aSLionel Sambuc template<int I> void ft4(S5<I>) { }
g2()119f4a2713aSLionel Sambuc void g2() {
120f4a2713aSLionel Sambuc   // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE
121f4a2713aSLionel Sambuc   ft4(S5<10>());
122f4a2713aSLionel Sambuc 
123f4a2713aSLionel Sambuc   // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE
124f4a2713aSLionel Sambuc   ft4(S5<20>());
125f4a2713aSLionel Sambuc }
126f4a2713aSLionel Sambuc 
127f4a2713aSLionel Sambuc extern "C++" {
128f4a2713aSLionel Sambuc   // CHECK: @_Z1hv
h()129f4a2713aSLionel Sambuc  void h() { }
130f4a2713aSLionel Sambuc }
131f4a2713aSLionel Sambuc 
132f4a2713aSLionel Sambuc // PR5019
133f4a2713aSLionel Sambuc extern "C" { struct a { int b; }; }
134f4a2713aSLionel Sambuc 
135f4a2713aSLionel Sambuc // CHECK: @_Z1fP1a
f(struct a * x)136f4a2713aSLionel Sambuc int f(struct a *x) {
137f4a2713aSLionel Sambuc     return x->b;
138f4a2713aSLionel Sambuc }
139f4a2713aSLionel Sambuc 
140f4a2713aSLionel Sambuc // PR5017
141f4a2713aSLionel Sambuc extern "C" {
142f4a2713aSLionel Sambuc struct Debug {
operator <<Debug143f4a2713aSLionel Sambuc   const Debug& operator<< (unsigned a) const { return *this; }
144f4a2713aSLionel Sambuc };
145f4a2713aSLionel Sambuc Debug dbg;
146f4a2713aSLionel Sambuc // CHECK: @_ZNK5DebuglsEj
main(void)147f4a2713aSLionel Sambuc int main(void) {  dbg << 32 ;}
148f4a2713aSLionel Sambuc }
149f4a2713aSLionel Sambuc 
150f4a2713aSLionel Sambuc template<typename T> struct S6 {
151f4a2713aSLionel Sambuc   typedef int B;
152f4a2713aSLionel Sambuc };
153f4a2713aSLionel Sambuc 
ft5(typename S6<T>::B)154f4a2713aSLionel Sambuc template<typename T> void ft5(typename S6<T>::B) { }
155f4a2713aSLionel Sambuc // CHECK: @_Z3ft5IiEvN2S6IT_E1BE
156f4a2713aSLionel Sambuc template void ft5<int>(int);
157f4a2713aSLionel Sambuc 
158f4a2713aSLionel Sambuc template<typename T> class A {};
159f4a2713aSLionel Sambuc 
160f4a2713aSLionel Sambuc namespace NS {
operator ==(const A<T> &,const A<T> &)161f4a2713aSLionel Sambuc template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
162f4a2713aSLionel Sambuc }
163f4a2713aSLionel Sambuc 
164f4a2713aSLionel Sambuc // CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_
165f4a2713aSLionel Sambuc template bool NS::operator==(const ::A<char>&, const ::A<char>&);
166f4a2713aSLionel Sambuc 
167f4a2713aSLionel Sambuc namespace std {
operator ==(const A<T> &,const A<T> &)168f4a2713aSLionel Sambuc template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
169f4a2713aSLionel Sambuc }
170f4a2713aSLionel Sambuc 
171f4a2713aSLionel Sambuc // CHECK: @_ZSteqIcEbRK1AIT_ES4_
172f4a2713aSLionel Sambuc template bool std::operator==(const ::A<char>&, const ::A<char>&);
173f4a2713aSLionel Sambuc 
174f4a2713aSLionel Sambuc struct S {
175f4a2713aSLionel Sambuc   typedef int U;
176f4a2713aSLionel Sambuc };
177f4a2713aSLionel Sambuc 
ft6(const T &)178f4a2713aSLionel Sambuc template <typename T> typename T::U ft6(const T&) { return 0; }
179f4a2713aSLionel Sambuc 
180f4a2713aSLionel Sambuc // CHECK: @_Z3ft6I1SENT_1UERKS1_
181f4a2713aSLionel Sambuc template int ft6<S>(const S&);
182f4a2713aSLionel Sambuc 
183f4a2713aSLionel Sambuc template<typename> struct __is_scalar_type {
184f4a2713aSLionel Sambuc   enum { __value = 1 };
185f4a2713aSLionel Sambuc };
186f4a2713aSLionel Sambuc 
187f4a2713aSLionel Sambuc template<bool, typename> struct __enable_if { };
188f4a2713aSLionel Sambuc 
189f4a2713aSLionel Sambuc template<typename T> struct __enable_if<true, T> {
190f4a2713aSLionel Sambuc   typedef T __type;
191f4a2713aSLionel Sambuc };
192f4a2713aSLionel Sambuc 
193f4a2713aSLionel Sambuc // PR5063
ft7()194f4a2713aSLionel Sambuc template<typename T> typename __enable_if<__is_scalar_type<T>::__value, void>::__type ft7() { }
195f4a2713aSLionel Sambuc 
196f4a2713aSLionel Sambuc // CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
197f4a2713aSLionel Sambuc template void ft7<int>();
198f4a2713aSLionel Sambuc // CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
199f4a2713aSLionel Sambuc template void ft7<void*>();
200f4a2713aSLionel Sambuc 
201f4a2713aSLionel Sambuc // PR5144
202f4a2713aSLionel Sambuc extern "C" {
203f4a2713aSLionel Sambuc void extern_f(void);
204f4a2713aSLionel Sambuc };
205f4a2713aSLionel Sambuc 
206f4a2713aSLionel Sambuc // CHECK: @extern_f
extern_f(void)207f4a2713aSLionel Sambuc void extern_f(void) { }
208f4a2713aSLionel Sambuc 
209f4a2713aSLionel Sambuc struct S7 {
210f4a2713aSLionel Sambuc   S7();
211f4a2713aSLionel Sambuc 
212f4a2713aSLionel Sambuc   struct S { S(); };
213f4a2713aSLionel Sambuc   struct {
214f4a2713aSLionel Sambuc     S s;
215f4a2713aSLionel Sambuc   } a;
216f4a2713aSLionel Sambuc };
217f4a2713aSLionel Sambuc 
218f4a2713aSLionel Sambuc // PR5139
219f4a2713aSLionel Sambuc // CHECK: @_ZN2S7C2Ev
220f4a2713aSLionel Sambuc // CHECK: @_ZN2S7Ut_C1Ev
221*0a6a1f1dSLionel Sambuc // CHECK: @_ZN2S7C1Ev
S7()222f4a2713aSLionel Sambuc S7::S7() {}
223f4a2713aSLionel Sambuc 
224f4a2713aSLionel Sambuc // PR5063
ft8()225f4a2713aSLionel Sambuc template<typename T> typename __enable_if<(__is_scalar_type<T>::__value), void>::__type ft8() { }
226f4a2713aSLionel Sambuc // CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
227f4a2713aSLionel Sambuc template void ft8<int>();
228f4a2713aSLionel Sambuc // CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
229f4a2713aSLionel Sambuc template void ft8<void*>();
230f4a2713aSLionel Sambuc 
231f4a2713aSLionel Sambuc // PR5796
232f4a2713aSLionel Sambuc namespace PR5796 {
233f4a2713aSLionel Sambuc template<typename> struct __is_scalar_type {
234f4a2713aSLionel Sambuc   enum { __value = 0 };
235f4a2713aSLionel Sambuc };
236f4a2713aSLionel Sambuc 
237f4a2713aSLionel Sambuc template<bool, typename> struct __enable_if {};
238f4a2713aSLionel Sambuc template<typename T> struct __enable_if<true, T> { typedef T __type; };
239f4a2713aSLionel Sambuc template<typename T>
240f4a2713aSLionel Sambuc 
241f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
__fill_a()242f4a2713aSLionel Sambuc typename __enable_if<!__is_scalar_type<T>::__value, void>::__type __fill_a() { };
243f4a2713aSLionel Sambuc 
f()244f4a2713aSLionel Sambuc void f() { __fill_a<int>(); }
245f4a2713aSLionel Sambuc }
246f4a2713aSLionel Sambuc 
247f4a2713aSLionel Sambuc namespace Expressions {
248f4a2713aSLionel Sambuc // Unary operators.
249f4a2713aSLionel Sambuc 
250f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN11Expressions2f1ILi1EEEvPAplngT_Li2E_i
f1(int (*)[(-i)+2])251f4a2713aSLionel Sambuc template <int i> void f1(int (*)[(-i) + 2]) { };
252f4a2713aSLionel Sambuc template void f1<1>(int (*)[1]);
253f4a2713aSLionel Sambuc 
254f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN11Expressions2f2ILi1EEEvPApsT__i
f2(int (*)[+i])255f4a2713aSLionel Sambuc template <int i> void f2(int (*)[+i]) { };
256f4a2713aSLionel Sambuc template void f2<1>(int (*)[1]);
257f4a2713aSLionel Sambuc 
258f4a2713aSLionel Sambuc // Binary operators.
259f4a2713aSLionel Sambuc 
260f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN11Expressions2f3ILi1EEEvPAplT_T__i
f3(int (*)[i+i])261f4a2713aSLionel Sambuc template <int i> void f3(int (*)[i+i]) { };
262f4a2713aSLionel Sambuc template void f3<1>(int (*)[2]);
263f4a2713aSLionel Sambuc 
264f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN11Expressions2f4ILi1EEEvPAplplLi2ET_T__i
f4(int (*)[2+i+i])265f4a2713aSLionel Sambuc template <int i> void f4(int (*)[2 + i+i]) { };
266f4a2713aSLionel Sambuc template void f4<1>(int (*)[4]);
267f4a2713aSLionel Sambuc 
268f4a2713aSLionel Sambuc // The ternary operator.
269f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN11Expressions2f4ILb1EEEvPAquT_Li1ELi2E_i
f4(int (*)[b?1:2])270f4a2713aSLionel Sambuc template <bool b> void f4(int (*)[b ? 1 : 2]) { };
271f4a2713aSLionel Sambuc template void f4<true>(int (*)[1]);
272f4a2713aSLionel Sambuc }
273f4a2713aSLionel Sambuc 
274f4a2713aSLionel Sambuc struct Ops {
275f4a2713aSLionel Sambuc   Ops& operator+(const Ops&);
276f4a2713aSLionel Sambuc   Ops& operator-(const Ops&);
277f4a2713aSLionel Sambuc   Ops& operator&(const Ops&);
278f4a2713aSLionel Sambuc   Ops& operator*(const Ops&);
279f4a2713aSLionel Sambuc 
280f4a2713aSLionel Sambuc   void *v;
281f4a2713aSLionel Sambuc };
282f4a2713aSLionel Sambuc 
283*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsplERKS_
operator +(const Ops &)284f4a2713aSLionel Sambuc Ops& Ops::operator+(const Ops&) { return *this; }
285*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsmiERKS_
operator -(const Ops &)286f4a2713aSLionel Sambuc Ops& Ops::operator-(const Ops&) { return *this; }
287*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsanERKS_
operator &(const Ops &)288f4a2713aSLionel Sambuc Ops& Ops::operator&(const Ops&) { return *this; }
289*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsmlERKS_
operator *(const Ops &)290f4a2713aSLionel Sambuc Ops& Ops::operator*(const Ops&) { return *this; }
291f4a2713aSLionel Sambuc 
292f4a2713aSLionel Sambuc // PR5861
293f4a2713aSLionel Sambuc namespace PR5861 {
294f4a2713aSLionel Sambuc template<bool> class P;
295f4a2713aSLionel Sambuc template<> class P<true> {};
296f4a2713aSLionel Sambuc 
297f4a2713aSLionel Sambuc template<template <bool> class, bool>
298f4a2713aSLionel Sambuc struct Policy { };
299f4a2713aSLionel Sambuc 
300f4a2713aSLionel Sambuc template<typename T, typename = Policy<P, true> > class Alloc
301f4a2713aSLionel Sambuc {
allocate(int,const void *)302f4a2713aSLionel Sambuc   T *allocate(int, const void*) { return 0; }
303f4a2713aSLionel Sambuc };
304f4a2713aSLionel Sambuc 
305f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr i8* @_ZN6PR58615AllocIcNS_6PolicyINS_1PELb1EEEE8allocateEiPKv
306f4a2713aSLionel Sambuc template class Alloc<char>;
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc 
309f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fU13block_pointerFiiiE
310f4a2713aSLionel Sambuc void f(int (^)(int, int)) { }
311f4a2713aSLionel Sambuc 
pr5966_foo()312f4a2713aSLionel Sambuc void pr5966_foo() {
313f4a2713aSLionel Sambuc   extern int pr5966_i;
314f4a2713aSLionel Sambuc   pr5966_i = 0;
315f4a2713aSLionel Sambuc }
316f4a2713aSLionel Sambuc 
317f4a2713aSLionel Sambuc static int pr5966_j;
318f4a2713aSLionel Sambuc 
pr5966_bar()319f4a2713aSLionel Sambuc void pr5966_bar() {
320f4a2713aSLionel Sambuc   pr5966_j = 0;
321f4a2713aSLionel Sambuc }
322f4a2713aSLionel Sambuc 
323f4a2713aSLionel Sambuc namespace test0 {
324f4a2713aSLionel Sambuc   int ovl(int x);
325f4a2713aSLionel Sambuc   char ovl(double x);
326f4a2713aSLionel Sambuc 
f(T,char (& buffer)[sizeof (ovl (T ()))])327f4a2713aSLionel Sambuc   template <class T> void f(T, char (&buffer)[sizeof(ovl(T()))]) {}
328f4a2713aSLionel Sambuc 
test0()329f4a2713aSLionel Sambuc   void test0() {
330f4a2713aSLionel Sambuc     char buffer[1];
331f4a2713aSLionel Sambuc     f(0.0, buffer);
332f4a2713aSLionel Sambuc   }
333f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN5test05test0Ev()
334f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01fIdEEvT_RAszcl3ovlcvS1__EE_c(
335f4a2713aSLionel Sambuc 
test1()336f4a2713aSLionel Sambuc   void test1() {
337f4a2713aSLionel Sambuc     char buffer[sizeof(int)];
338f4a2713aSLionel Sambuc     f(1, buffer);
339f4a2713aSLionel Sambuc   }
340f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN5test05test1Ev()
341f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01fIiEEvT_RAszcl3ovlcvS1__EE_c(
342f4a2713aSLionel Sambuc 
g(char (& buffer)[sizeof (T ()+5.0f)])343f4a2713aSLionel Sambuc   template <class T> void g(char (&buffer)[sizeof(T() + 5.0f)]) {}
test2()344f4a2713aSLionel Sambuc   void test2() {
345f4a2713aSLionel Sambuc     char buffer[sizeof(float)];
346f4a2713aSLionel Sambuc     g<float>(buffer);
347f4a2713aSLionel Sambuc   }
348f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01gIfEEvRAszplcvT__ELf40a00000E_c(
349f4a2713aSLionel Sambuc 
h(char (& buffer)[sizeof (T ()+5.0)])350f4a2713aSLionel Sambuc   template <class T> void h(char (&buffer)[sizeof(T() + 5.0)]) {}
test3()351f4a2713aSLionel Sambuc   void test3() {
352f4a2713aSLionel Sambuc     char buffer[sizeof(double)];
353f4a2713aSLionel Sambuc     h<float>(buffer);
354f4a2713aSLionel Sambuc   }
355f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01hIfEEvRAszplcvT__ELd4014000000000000E_c(
356f4a2713aSLionel Sambuc 
j(char (& buffer)[sizeof (T ().buffer)])357f4a2713aSLionel Sambuc   template <class T> void j(char (&buffer)[sizeof(T().buffer)]) {}
358f4a2713aSLionel Sambuc   struct A { double buffer[128]; };
test4()359f4a2713aSLionel Sambuc   void test4() {
360f4a2713aSLionel Sambuc     char buffer[1024];
361f4a2713aSLionel Sambuc     j<A>(buffer);
362f4a2713aSLionel Sambuc   }
363f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
364f4a2713aSLionel Sambuc 
k(char (& buffer)[sizeof (T ()+0.0f)])365f4a2713aSLionel Sambuc   template <class T> void k(char (&buffer)[sizeof(T() + 0.0f)]) {}
test5()366f4a2713aSLionel Sambuc   void test5() {
367f4a2713aSLionel Sambuc     char buffer[sizeof(float)];
368f4a2713aSLionel Sambuc     k<float>(buffer);
369f4a2713aSLionel Sambuc   }
370f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN5test01kIfEEvRAszplcvT__ELf00000000E_c(
371f4a2713aSLionel Sambuc 
372f4a2713aSLionel Sambuc }
373f4a2713aSLionel Sambuc 
374f4a2713aSLionel Sambuc namespace test1 {
375f4a2713aSLionel Sambuc   template<typename T> struct X { };
f(Y<T>)376f4a2713aSLionel Sambuc   template<template<class> class Y, typename T> void f(Y<T>) { }
377f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN5test11fINS_1XEiEEvT_IT0_E
378f4a2713aSLionel Sambuc   template void f(X<int>);
379f4a2713aSLionel Sambuc }
380f4a2713aSLionel Sambuc 
381f4a2713aSLionel Sambuc // CHECK-LABEL: define internal void @_ZL27functionWithInternalLinkagev()
functionWithInternalLinkage()382f4a2713aSLionel Sambuc static void functionWithInternalLinkage() {  }
g()383f4a2713aSLionel Sambuc void g() { functionWithInternalLinkage(); }
384f4a2713aSLionel Sambuc 
385f4a2713aSLionel Sambuc namespace test2 {
read_member(T & obj)386f4a2713aSLionel Sambuc   template <class T> decltype(((T*) 0)->member) read_member(T& obj) {
387f4a2713aSLionel Sambuc     return obj.member;
388f4a2713aSLionel Sambuc   }
389f4a2713aSLionel Sambuc 
390f4a2713aSLionel Sambuc   struct A { int member; } obj;
test()391f4a2713aSLionel Sambuc   int test() {
392f4a2713aSLionel Sambuc     return read_member(obj);
393f4a2713aSLionel Sambuc   }
394f4a2713aSLionel Sambuc 
395f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr i32 @_ZN5test211read_memberINS_1AEEEDtptcvPT_Li0E6memberERS2_(
396f4a2713aSLionel Sambuc }
397f4a2713aSLionel Sambuc 
398f4a2713aSLionel Sambuc // rdar://problem/9280586
399f4a2713aSLionel Sambuc namespace test3 {
400f4a2713aSLionel Sambuc   struct AmbiguousBase { int ab; };
401f4a2713aSLionel Sambuc   struct Path1 : AmbiguousBase { float p; };
402f4a2713aSLionel Sambuc   struct Path2 : AmbiguousBase { double p; };
403f4a2713aSLionel Sambuc   struct Derived : Path1, Path2 { };
404f4a2713aSLionel Sambuc 
405f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr i32 @_ZN5test38get_ab_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E2abERS2_(
get_ab_1(T & ref)406f4a2713aSLionel Sambuc   template <class T> decltype(((T*) 0)->Path1::ab) get_ab_1(T &ref) { return ref.Path1::ab; }
407f4a2713aSLionel Sambuc 
408f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr i32 @_ZN5test38get_ab_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E2abERS2_(
get_ab_2(T & ref)409f4a2713aSLionel Sambuc   template <class T> decltype(((T*) 0)->Path2::ab) get_ab_2(T &ref) { return ref.Path2::ab; }
410f4a2713aSLionel Sambuc 
411f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E1pERS2_(
get_p_1(T & ref)412f4a2713aSLionel Sambuc   template <class T> decltype(((T*) 0)->Path1::p) get_p_1(T &ref) { return ref.Path1::p; }
413f4a2713aSLionel Sambuc 
414f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr double @_ZN5test37get_p_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E1pERS2_(
get_p_2(T & ref)415f4a2713aSLionel Sambuc   template <class T> decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; }
416f4a2713aSLionel Sambuc 
417f4a2713aSLionel Sambuc   Derived obj;
test()418f4a2713aSLionel Sambuc   void test() {
419f4a2713aSLionel Sambuc     get_ab_1(obj);
420f4a2713aSLionel Sambuc     get_ab_2(obj);
421f4a2713aSLionel Sambuc     get_p_1(obj);
422f4a2713aSLionel Sambuc     get_p_2(obj);
423f4a2713aSLionel Sambuc   }
424f4a2713aSLionel Sambuc }
425f4a2713aSLionel Sambuc 
426f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN5test41gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
427f4a2713aSLionel Sambuc namespace test4 {
428f4a2713aSLionel Sambuc   struct foo { int bar; };
429f4a2713aSLionel Sambuc   template <int (foo::*)>
430f4a2713aSLionel Sambuc   struct zed {};
g(zed<& foo::bar> *)431f4a2713aSLionel Sambuc   void g(zed<&foo::bar>*)
432f4a2713aSLionel Sambuc   {}
433f4a2713aSLionel Sambuc }
434f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN5test51gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
435f4a2713aSLionel Sambuc namespace test5 {
436f4a2713aSLionel Sambuc   struct foo { static int bar; };
437f4a2713aSLionel Sambuc   template <int *>
438f4a2713aSLionel Sambuc   struct zed {};
g(zed<& foo::bar> *)439f4a2713aSLionel Sambuc   void g(zed<&foo::bar>*)
440f4a2713aSLionel Sambuc   {}
441f4a2713aSLionel Sambuc }
442f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN5test61gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
443f4a2713aSLionel Sambuc namespace test6 {
444f4a2713aSLionel Sambuc   struct foo { int bar(); };
445f4a2713aSLionel Sambuc   template <int (foo::*)()>
446f4a2713aSLionel Sambuc   struct zed {};
g(zed<& foo::bar> *)447f4a2713aSLionel Sambuc   void g(zed<&foo::bar>*)
448f4a2713aSLionel Sambuc   {}
449f4a2713aSLionel Sambuc }
450f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN5test71gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
451f4a2713aSLionel Sambuc namespace test7 {
452f4a2713aSLionel Sambuc   struct foo { static int bar(); };
453f4a2713aSLionel Sambuc   template <int (*f)()>
454f4a2713aSLionel Sambuc   struct zed {};
g(zed<& foo::bar> *)455f4a2713aSLionel Sambuc   void g(zed<&foo::bar>*)
456f4a2713aSLionel Sambuc   {}
457f4a2713aSLionel Sambuc }
458f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_ZN5test81AILZNS_1B5valueEEE3incEv
459f4a2713aSLionel Sambuc namespace test8 {
inc()460f4a2713aSLionel Sambuc   template <int &counter> class A { void inc() { counter++; } };
461f4a2713aSLionel Sambuc   class B { public: static int value; };
462f4a2713aSLionel Sambuc   template class A<B::value>;
463f4a2713aSLionel Sambuc }
464f4a2713aSLionel Sambuc // CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE
465f4a2713aSLionel Sambuc namespace test9 {
466f4a2713aSLionel Sambuc   template<class T>
467f4a2713aSLionel Sambuc   struct foo {
468f4a2713aSLionel Sambuc     typedef T X;
469f4a2713aSLionel Sambuc   };
470f4a2713aSLionel Sambuc   struct bar {
471f4a2713aSLionel Sambuc     typedef foo<int> baz;
472f4a2713aSLionel Sambuc   };
473f4a2713aSLionel Sambuc   template <class zaz, class zed>
474f4a2713aSLionel Sambuc   void f(const typename zed::baz::X&);
g()475f4a2713aSLionel Sambuc   void g() {
476f4a2713aSLionel Sambuc     f<int, bar>( 0);
477f4a2713aSLionel Sambuc   }
478f4a2713aSLionel Sambuc }
479f4a2713aSLionel Sambuc 
480f4a2713aSLionel Sambuc // <rdar://problem/7825453>
481f4a2713aSLionel Sambuc namespace test10 {
482f4a2713aSLionel Sambuc   template <char P1> struct S {};
f(struct S<false?'a':P2>)483f4a2713aSLionel Sambuc   template <char P2> void f(struct S<false ? 'a' : P2> ) {}
484f4a2713aSLionel Sambuc 
485f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test101fILc3EEEvNS_1SIXquLb0ELc97ET_EEE(
486f4a2713aSLionel Sambuc   template void f<(char) 3>(struct S<3>);
487f4a2713aSLionel Sambuc }
488f4a2713aSLionel Sambuc 
489f4a2713aSLionel Sambuc namespace test11 {
490f4a2713aSLionel Sambuc   // CHECK: @_ZN6test111fEz
f(...)491f4a2713aSLionel Sambuc   void f(...) { }
492f4a2713aSLionel Sambuc 
493f4a2713aSLionel Sambuc   struct A {
494f4a2713aSLionel Sambuc     void f(...);
495f4a2713aSLionel Sambuc   };
496f4a2713aSLionel Sambuc 
497f4a2713aSLionel Sambuc   // CHECK: @_ZN6test111A1fEz
f(...)498f4a2713aSLionel Sambuc   void A::f(...) { }
499f4a2713aSLionel Sambuc }
500f4a2713aSLionel Sambuc 
501f4a2713aSLionel Sambuc namespace test12 {
502f4a2713aSLionel Sambuc 
503f4a2713aSLionel Sambuc   // CHECK: _ZN6test121fENS_1AILt33000EEE
504f4a2713aSLionel Sambuc   template <unsigned short> struct A { };
f(A<33000>)505f4a2713aSLionel Sambuc   void f(A<33000>) { }
506f4a2713aSLionel Sambuc }
507f4a2713aSLionel Sambuc 
508f4a2713aSLionel Sambuc // PR7446
509f4a2713aSLionel Sambuc namespace test13 {
510f4a2713aSLionel Sambuc   template <template <class> class T> class A {};
511f4a2713aSLionel Sambuc   template <class U> class B {};
512f4a2713aSLionel Sambuc 
foo(const A<T> & a)513f4a2713aSLionel Sambuc   template <template<class> class T> void foo(const A<T> &a) {}
514f4a2713aSLionel Sambuc 
515f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE(
516f4a2713aSLionel Sambuc   template void foo(const A<B> &a);
517f4a2713aSLionel Sambuc }
518f4a2713aSLionel Sambuc 
519f4a2713aSLionel Sambuc namespace test14 {
520f4a2713aSLionel Sambuc   extern "C" {
521f4a2713aSLionel Sambuc     struct S {
522f4a2713aSLionel Sambuc       static int a(), x;
523f4a2713aSLionel Sambuc     };
524f4a2713aSLionel Sambuc     // CHECK-LABEL: define i32 @_ZN6test141S1aEv
525f4a2713aSLionel Sambuc     // CHECK: load i32* @_ZN6test141S1xE
a()526f4a2713aSLionel Sambuc     int S::a() { return S::x; }
527f4a2713aSLionel Sambuc   }
528f4a2713aSLionel Sambuc }
529f4a2713aSLionel Sambuc 
530f4a2713aSLionel Sambuc // rdar://problem/8204122
531f4a2713aSLionel Sambuc namespace test15 {
532f4a2713aSLionel Sambuc   enum E { e = 3 };
533f4a2713aSLionel Sambuc   template <int I> struct S {};
534f4a2713aSLionel Sambuc 
f(S<I+e>)535f4a2713aSLionel Sambuc   template <int I> void f(S<I + e>) {}
536f4a2713aSLionel Sambuc 
537f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE(
538f4a2713aSLionel Sambuc   template void f<7>(S<7 + e>);
539f4a2713aSLionel Sambuc }
540f4a2713aSLionel Sambuc 
541f4a2713aSLionel Sambuc // rdar://problem/8302148
542f4a2713aSLionel Sambuc namespace test17 {
543f4a2713aSLionel Sambuc   template <int N> struct A {};
544f4a2713aSLionel Sambuc 
545f4a2713aSLionel Sambuc   struct B {
546f4a2713aSLionel Sambuc     static int foo(void);
547f4a2713aSLionel Sambuc   };
548f4a2713aSLionel Sambuc 
549f4a2713aSLionel Sambuc   template <class T> A<sizeof(T::foo())> func(void);
550f4a2713aSLionel Sambuc 
551f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test174testEv()
552f4a2713aSLionel Sambuc   // CHECK: call {{.*}} @_ZN6test174funcINS_1BEEENS_1AIXszclsrT_3fooEEEEv()
test()553f4a2713aSLionel Sambuc   void test() {
554f4a2713aSLionel Sambuc     func<B>();
555f4a2713aSLionel Sambuc   }
556f4a2713aSLionel Sambuc }
557f4a2713aSLionel Sambuc 
558f4a2713aSLionel Sambuc // PR7891
559f4a2713aSLionel Sambuc namespace test18 {
560f4a2713aSLionel Sambuc   struct A {
561f4a2713aSLionel Sambuc     int operator+();
562f4a2713aSLionel Sambuc     int operator-();
563f4a2713aSLionel Sambuc     int operator*();
564f4a2713aSLionel Sambuc     int operator&();
565f4a2713aSLionel Sambuc   };
566f4a2713aSLionel Sambuc   template <int (A::*)()> struct S {};
567f4a2713aSLionel Sambuc 
f(S<& T::operator+>)568f4a2713aSLionel Sambuc   template <typename T> void f(S<&T::operator+>) {}
569f4a2713aSLionel Sambuc   template void f<A>(S<&A::operator+>);
570f4a2713aSLionel Sambuc 
f(S<& T::operator->)571f4a2713aSLionel Sambuc   template <typename T> void f(S<&T::operator- >) {}
572f4a2713aSLionel Sambuc   template void f<A>(S<&A::operator- >);
573f4a2713aSLionel Sambuc 
f(S<& T::operator * >)574f4a2713aSLionel Sambuc   template <typename T> void f(S<&T::operator*>) {}
575f4a2713aSLionel Sambuc   template void f<A>(S<&A::operator*>);
576f4a2713aSLionel Sambuc 
f(S<& T::operator &>)577f4a2713aSLionel Sambuc   template <typename T> void f(S<&T::operator&>) {}
578f4a2713aSLionel Sambuc   template void f<A>(S<&A::operator&>);
579f4a2713aSLionel Sambuc 
580f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_plEEE
581f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_miEEE
582f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_mlEEE
583f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_anEEE
584f4a2713aSLionel Sambuc }
585f4a2713aSLionel Sambuc 
586f4a2713aSLionel Sambuc // rdar://problem/8332117
587f4a2713aSLionel Sambuc namespace test19 {
588f4a2713aSLionel Sambuc   struct A {
589f4a2713aSLionel Sambuc     template <typename T> int f();
590f4a2713aSLionel Sambuc     int operator+();
591f4a2713aSLionel Sambuc     operator int();
592f4a2713aSLionel Sambuc     template <typename T> int operator-();
593f4a2713aSLionel Sambuc   };
594f4a2713aSLionel Sambuc 
595f4a2713aSLionel Sambuc   template <int (A::*)()> struct S {};
596f4a2713aSLionel Sambuc 
g(S<& T::template f<int>>)597f4a2713aSLionel Sambuc   template <typename T> void g (S<&T::template f<int> >) {}
g(S<& T::operator+>)598f4a2713aSLionel Sambuc   template <typename T> void g (S<&T::operator+ >) {}
g(S<& T::operator int>)599f4a2713aSLionel Sambuc   template <typename T> void g (S<&T::operator int>) {}
g(S<& T::template operator-<double>>)600f4a2713aSLionel Sambuc   template <typename T> void g (S<&T::template operator- <double> >) {}
601f4a2713aSLionel Sambuc 
602f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_1fIiEEEE(
603f4a2713aSLionel Sambuc   template void g<A>(S<&A::f<int> >);
604f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_plEEE(
605f4a2713aSLionel Sambuc   template void g<A>(S<&A::operator+>);
606f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_cviEEE(
607f4a2713aSLionel Sambuc   template void g<A>(S<&A::operator int>);
608f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_miIdEEEE(
609f4a2713aSLionel Sambuc   template void g<A>(S<&A::operator-<double> >);
610f4a2713aSLionel Sambuc }
611f4a2713aSLionel Sambuc 
612f4a2713aSLionel Sambuc namespace test20 {
613f4a2713aSLionel Sambuc   template <class T> T *f(const T&);
614f4a2713aSLionel Sambuc   template <class T> T *f(T*);
615f4a2713aSLionel Sambuc 
616f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test205test0IiEEvDTcl1fIPT_ELi0EEE(
test0(decltype(f<T * > (0)) )617f4a2713aSLionel Sambuc   template <class T> void test0(decltype(f<T*>(0))) {}
618f4a2713aSLionel Sambuc   template void test0<int>(decltype(f<int*>(0)));
619f4a2713aSLionel Sambuc 
620f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test205test1IiEEvDTcl1fIEcvT__EEE(
test1(decltype(f<> (T ())) )621f4a2713aSLionel Sambuc   template <class T> void test1(decltype(f<>(T()))) {}
622f4a2713aSLionel Sambuc   template void test1<int>(decltype(f<>(int())));
623f4a2713aSLionel Sambuc }
624f4a2713aSLionel Sambuc 
625f4a2713aSLionel Sambuc // rdar:// 8620510
626f4a2713aSLionel Sambuc namespace test21 {
627f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test2112vla_arg_funcEiPA_i(
vla_arg_func(int X,int a[X][X])628f4a2713aSLionel Sambuc   void vla_arg_func(int X, int a[X][X]) {}
629f4a2713aSLionel Sambuc }
630f4a2713aSLionel Sambuc 
631f4a2713aSLionel Sambuc namespace test22 {
632f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test221fEDn(
f(decltype(nullptr) )633f4a2713aSLionel Sambuc   void f(decltype(nullptr)) { }
634f4a2713aSLionel Sambuc }
635f4a2713aSLionel Sambuc 
636f4a2713aSLionel Sambuc // rdar://problem/8913416
637f4a2713aSLionel Sambuc namespace test23 {
638f4a2713aSLionel Sambuc   typedef void * const vpc;
639f4a2713aSLionel Sambuc 
640f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test231fERA10_KPv(
f(vpc (&)[10])641f4a2713aSLionel Sambuc   void f(vpc (&)[10]) {}
642f4a2713aSLionel Sambuc 
643f4a2713aSLionel Sambuc   typedef vpc vpca5[5];
f(vpca5 volatile (&)[10])644f4a2713aSLionel Sambuc   void f(vpca5 volatile (&)[10]) {}
645f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test231fERA10_A5_VKPv(
646f4a2713aSLionel Sambuc }
647f4a2713aSLionel Sambuc 
648f4a2713aSLionel Sambuc namespace test24 {
test0()649f4a2713aSLionel Sambuc   void test0() {
650f4a2713aSLionel Sambuc     extern int foo();
651f4a2713aSLionel Sambuc     // CHECK: call i32 @_ZN6test243fooEv()
652f4a2713aSLionel Sambuc     foo();
653f4a2713aSLionel Sambuc   }
654f4a2713aSLionel Sambuc 
bar()655f4a2713aSLionel Sambuc   static char bar() {}
test1()656f4a2713aSLionel Sambuc   void test1() {
657f4a2713aSLionel Sambuc     // CHECK: call signext i8 @_ZN6test24L3barEv()
658f4a2713aSLionel Sambuc     bar();
659f4a2713aSLionel Sambuc   }
660f4a2713aSLionel Sambuc }
661f4a2713aSLionel Sambuc 
662f4a2713aSLionel Sambuc // rdar://problem/8806641
663f4a2713aSLionel Sambuc namespace test25 {
664f4a2713aSLionel Sambuc   template <void (*fn)()> struct A {
calltest25::A665f4a2713aSLionel Sambuc     static void call() { fn(); }
666f4a2713aSLionel Sambuc   };
667f4a2713aSLionel Sambuc   void foo();
test()668f4a2713aSLionel Sambuc   void test() {
669f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test251AIXadL_ZNS_3fooEvEEE4callEv()
670f4a2713aSLionel Sambuc     A<foo>::call();
671f4a2713aSLionel Sambuc   }
672f4a2713aSLionel Sambuc }
673f4a2713aSLionel Sambuc 
674f4a2713aSLionel Sambuc namespace test26 {
foo(decltype(T<float>::object) & object)675f4a2713aSLionel Sambuc   template <template <class> class T> void foo(decltype(T<float>::object) &object) {}
676f4a2713aSLionel Sambuc 
677f4a2713aSLionel Sambuc   template <class T> struct holder { static T object; };
678f4a2713aSLionel Sambuc 
test()679f4a2713aSLionel Sambuc   void test() {
680f4a2713aSLionel Sambuc     float f;
681f4a2713aSLionel Sambuc 
682f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test263fooINS_6holderEEEvRDtsrT_IfE6objectE(
683f4a2713aSLionel Sambuc     foo<holder>(f);
684f4a2713aSLionel Sambuc   }
685f4a2713aSLionel Sambuc }
686f4a2713aSLionel Sambuc 
687f4a2713aSLionel Sambuc namespace test27 {
688f4a2713aSLionel Sambuc   struct A {
689f4a2713aSLionel Sambuc     struct inner {
690f4a2713aSLionel Sambuc       float object;
691f4a2713aSLionel Sambuc     };
692f4a2713aSLionel Sambuc 
693f4a2713aSLionel Sambuc     float meth();
694f4a2713aSLionel Sambuc   };
695f4a2713aSLionel Sambuc   typedef A Alias;
696f4a2713aSLionel Sambuc 
a(decltype(T::inner::object) & object)697f4a2713aSLionel Sambuc   template <class T> void a(decltype(T::inner::object) &object) {}
T()698f4a2713aSLionel Sambuc   template <class T> void b(decltype(T().Alias::meth()) &object) {}
699f4a2713aSLionel Sambuc 
test()700f4a2713aSLionel Sambuc   void test() {
701f4a2713aSLionel Sambuc     float f;
702f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test271aINS_1AEEEvRDtsrNT_5innerE6objectE(
703f4a2713aSLionel Sambuc     a<A>(f);
704f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test271bINS_1AEEEvRDTcldtcvT__Esr5AliasE4methEE(
705f4a2713aSLionel Sambuc     b<A>(f);
706f4a2713aSLionel Sambuc   }
707f4a2713aSLionel Sambuc }
708f4a2713aSLionel Sambuc 
709f4a2713aSLionel Sambuc // An injected class name type in a unresolved-name.
710f4a2713aSLionel Sambuc namespace test28 {
711f4a2713aSLionel Sambuc   template <class T> struct A {
712f4a2713aSLionel Sambuc     enum { bit };
713f4a2713aSLionel Sambuc   };
714f4a2713aSLionel Sambuc 
715f4a2713aSLionel Sambuc   template <class T> void foo(decltype(A<T>::A::bit) x);
716f4a2713aSLionel Sambuc 
test()717f4a2713aSLionel Sambuc   void test() {
718f4a2713aSLionel Sambuc     foo<char>(A<char>::bit);
719f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test283fooIcEEvDtsr1AIT_E1AE3bitE(
720f4a2713aSLionel Sambuc   }
721f4a2713aSLionel Sambuc }
722f4a2713aSLionel Sambuc 
723f4a2713aSLionel Sambuc // An enclosing template type parameter in an unresolved-name.
724f4a2713aSLionel Sambuc namespace test29 {
725f4a2713aSLionel Sambuc   template <class T> struct A {
726f4a2713aSLionel Sambuc     template <class U> static void foo(decltype(T::fn(U())) x);
727f4a2713aSLionel Sambuc   };
728f4a2713aSLionel Sambuc   struct B { static int fn(int); static long fn(long); };
729f4a2713aSLionel Sambuc 
test()730f4a2713aSLionel Sambuc   void test() {
731f4a2713aSLionel Sambuc     A<B>::foo<int>(0);
732f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test291AINS_1BEE3fooIiEEvDTclsrS1_2fncvT__EEE(
733f4a2713aSLionel Sambuc   }
734f4a2713aSLionel Sambuc }
735f4a2713aSLionel Sambuc 
736f4a2713aSLionel Sambuc // An enclosing template template parameter in an unresolved-name.
737f4a2713aSLionel Sambuc namespace test30 {
738f4a2713aSLionel Sambuc   template <template <class> class T> struct A {
739f4a2713aSLionel Sambuc     template <class U> static void foo(decltype(T<U>::fn()) x);
740f4a2713aSLionel Sambuc   };
741f4a2713aSLionel Sambuc   template <class T> struct B { static T fn(); };
742f4a2713aSLionel Sambuc 
test()743f4a2713aSLionel Sambuc   void test() {
744f4a2713aSLionel Sambuc     A<B>::foo<int>(0);
745f4a2713aSLionel Sambuc     // CHECK: call void @_ZN6test301AINS_1BEE3fooIiEEvDTclsrS1_IT_EE2fnEE(
746f4a2713aSLionel Sambuc   }
747f4a2713aSLionel Sambuc }
748f4a2713aSLionel Sambuc 
749f4a2713aSLionel Sambuc namespace test31 { // instantiation-dependent mangling of decltype
750f4a2713aSLionel Sambuc   int x;
f1(T p)751f4a2713aSLionel Sambuc   template<class T> auto f1(T p)->decltype(x) { return 0; }
752f4a2713aSLionel Sambuc   // The return type in the mangling of the template signature
753f4a2713aSLionel Sambuc   // is encoded as "i".
f2(T p)754f4a2713aSLionel Sambuc   template<class T> auto f2(T p)->decltype(p) { return 0; }
755f4a2713aSLionel Sambuc   // The return type in the mangling of the template signature
756f4a2713aSLionel Sambuc   // is encoded as "Dtfp_E".
757f4a2713aSLionel Sambuc   void g(int);
f3(T p)758f4a2713aSLionel Sambuc   template<class T> auto f3(T p)->decltype(g(p)) {}
759f4a2713aSLionel Sambuc 
760f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr i32 @_ZN6test312f1IiEEiT_(
761f4a2713aSLionel Sambuc   template int f1(int);
762f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr i32 @_ZN6test312f2IiEEDtfp_ET_
763f4a2713aSLionel Sambuc   template int f2(int);
764f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test312f3IiEEDTcl1gfp_EET_
765f4a2713aSLionel Sambuc   template void f3(int);
766f4a2713aSLionel Sambuc }
767f4a2713aSLionel Sambuc 
768f4a2713aSLionel Sambuc // PR10205
769f4a2713aSLionel Sambuc namespace test32 {
770f4a2713aSLionel Sambuc   template<typename T, int=T::value> struct A {
771f4a2713aSLionel Sambuc     typedef int type;
772f4a2713aSLionel Sambuc   };
773f4a2713aSLionel Sambuc   struct B { enum { value = 4 }; };
774f4a2713aSLionel Sambuc 
foo()775f4a2713aSLionel Sambuc   template <class T> typename A<T>::type foo() { return 0; }
test()776f4a2713aSLionel Sambuc   void test() {
777f4a2713aSLionel Sambuc     foo<B>();
778f4a2713aSLionel Sambuc     // CHECK: call i32 @_ZN6test323fooINS_1BEEENS_1AIT_XsrS3_5valueEE4typeEv()
779f4a2713aSLionel Sambuc   }
780f4a2713aSLionel Sambuc }
781f4a2713aSLionel Sambuc 
782f4a2713aSLionel Sambuc namespace test33 {
783f4a2713aSLionel Sambuc   template <class T> struct X {
784f4a2713aSLionel Sambuc     enum { value = T::value };
785f4a2713aSLionel Sambuc   };
786f4a2713aSLionel Sambuc 
787f4a2713aSLionel Sambuc   template<typename T, int=X<T>::value> struct A {
788f4a2713aSLionel Sambuc     typedef int type;
789f4a2713aSLionel Sambuc   };
790f4a2713aSLionel Sambuc   struct B { enum { value = 4 }; };
791f4a2713aSLionel Sambuc 
foo()792f4a2713aSLionel Sambuc   template <class T> typename A<T>::type foo() { return 0; }
793f4a2713aSLionel Sambuc 
test()794f4a2713aSLionel Sambuc   void test() {
795f4a2713aSLionel Sambuc     foo<B>();
796f4a2713aSLionel Sambuc     // CHECK: call i32 @_ZN6test333fooINS_1BEEENS_1AIT_Xsr1XIS3_EE5valueEE4typeEv()
797f4a2713aSLionel Sambuc   }
798f4a2713aSLionel Sambuc }
799f4a2713aSLionel Sambuc 
800f4a2713aSLionel Sambuc namespace test34 {
801f4a2713aSLionel Sambuc   // Mangling for instantiation-dependent decltype expressions.
802f4a2713aSLionel Sambuc   template<typename T>
T()803f4a2713aSLionel Sambuc   void f(decltype(sizeof(decltype(T() + T())))) {}
804f4a2713aSLionel Sambuc 
805f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
806f4a2713aSLionel Sambuc   template void f<int>(decltype(sizeof(1)));
807f4a2713aSLionel Sambuc 
808f4a2713aSLionel Sambuc   // Mangling for non-instantiation-dependent sizeof expressions.
809f4a2713aSLionel Sambuc   template<unsigned N>
f2(int (&)[N+sizeof (int *)])810f4a2713aSLionel Sambuc   void f2(int (&)[N + sizeof(int*)]) {}
811f4a2713aSLionel Sambuc 
812f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test342f2ILj4EEEvRAplT_Lm8E_i
813f4a2713aSLionel Sambuc   template void f2<4>(int (&)[4 + sizeof(int*)]);
814f4a2713aSLionel Sambuc 
815f4a2713aSLionel Sambuc   // Mangling for non-instantiation-dependent sizeof expressions
816f4a2713aSLionel Sambuc   // involving an implicit conversion of the result of the sizeof.
817f4a2713aSLionel Sambuc   template<unsigned long long N>
f3(int (&)[N+sizeof (int *)])818f4a2713aSLionel Sambuc   void f3(int (&)[N + sizeof(int*)]) {}
819f4a2713aSLionel Sambuc 
820f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test342f3ILy4EEEvRAplT_Ly8E_i
821f4a2713aSLionel Sambuc   template void f3<4>(int (&)[4 + sizeof(int*)]);
822f4a2713aSLionel Sambuc 
823f4a2713aSLionel Sambuc   // Mangling for instantiation-dependent sizeof() expressions as
824f4a2713aSLionel Sambuc   // template arguments.
825f4a2713aSLionel Sambuc   template<unsigned> struct A { };
826f4a2713aSLionel Sambuc 
f4(::test34::A<sizeof (sizeof (decltype(T ()+T ()) ))>)827f4a2713aSLionel Sambuc   template<typename T> void f4(::test34::A<sizeof(sizeof(decltype(T() + T())))>) { }
828f4a2713aSLionel Sambuc 
829f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test342f4IiEEvNS_1AIXszstDTplcvT__EcvS2__EEEEE
830f4a2713aSLionel Sambuc   template void f4<int>(A<sizeof(sizeof(int))>);
831f4a2713aSLionel Sambuc }
832f4a2713aSLionel Sambuc 
833f4a2713aSLionel Sambuc namespace test35 {
834f4a2713aSLionel Sambuc   // Dependent operator names of unknown arity.
835f4a2713aSLionel Sambuc   struct A {
836f4a2713aSLionel Sambuc     template<typename U> A operator+(U) const;
837f4a2713aSLionel Sambuc   };
838f4a2713aSLionel Sambuc 
839f4a2713aSLionel Sambuc   template<typename T>
840f4a2713aSLionel Sambuc   void f1(decltype(sizeof(&T::template operator+<int>))) {}
841f4a2713aSLionel Sambuc 
842f4a2713aSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test352f1INS_1AEEEvDTszadsrT_plIiEE
843f4a2713aSLionel Sambuc   template void f1<A>(__SIZE_TYPE__);
844f4a2713aSLionel Sambuc }
845f4a2713aSLionel Sambuc 
846f4a2713aSLionel Sambuc namespace test36 {
847f4a2713aSLionel Sambuc   template<unsigned> struct A { };
848f4a2713aSLionel Sambuc 
849f4a2713aSLionel Sambuc   template<typename ...Types>
f1(Types...values)850f4a2713aSLionel Sambuc   auto f1(Types... values) -> A<sizeof...(values)> { }
851f4a2713aSLionel Sambuc 
852f4a2713aSLionel Sambuc   // CHECK: define weak_odr {{.*}} @_ZN6test362f1IJifEEENS_1AIXsZfp_EEEDpT_
853f4a2713aSLionel Sambuc   template A<2> f1(int, float);
854f4a2713aSLionel Sambuc }
855f4a2713aSLionel Sambuc 
856f4a2713aSLionel Sambuc namespace test37 {
857f4a2713aSLionel Sambuc   struct foo {
858f4a2713aSLionel Sambuc     struct {
859f4a2713aSLionel Sambuc     } a;
860f4a2713aSLionel Sambuc     typedef struct { } b;
861f4a2713aSLionel Sambuc     typedef struct { } *c;
862f4a2713aSLionel Sambuc     struct {
863f4a2713aSLionel Sambuc     } d;
864f4a2713aSLionel Sambuc   };
func(T)865f4a2713aSLionel Sambuc   template<typename T> void func(T) { }
test()866f4a2713aSLionel Sambuc   void test() {
867f4a2713aSLionel Sambuc     // CHECK-LABEL: define linkonce_odr void @_ZN6test374funcINS_3fooUt_EEEvT_
868f4a2713aSLionel Sambuc     func(foo().a);
869f4a2713aSLionel Sambuc     // CHECK-LABEL: define linkonce_odr void @_ZN6test374funcINS_3fooUt0_EEEvT_
870f4a2713aSLionel Sambuc     func(*foo::c());
871f4a2713aSLionel Sambuc     // CHECK-LABEL: define linkonce_odr void @_ZN6test374funcINS_3fooUt1_EEEvT_
872f4a2713aSLionel Sambuc     func(foo().d);
873f4a2713aSLionel Sambuc   }
874f4a2713aSLionel Sambuc }
875f4a2713aSLionel Sambuc 
876f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z6ASfuncPU3AS3i
ASfunc(int * x)877f4a2713aSLionel Sambuc void ASfunc(__attribute__((address_space(3))) int* x) {}
878f4a2713aSLionel Sambuc 
879f4a2713aSLionel Sambuc namespace test38 {
880f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN6test384funcINS_3fooUt_EEEvT_
881f4a2713aSLionel Sambuc   typedef struct {
882f4a2713aSLionel Sambuc     struct {
883f4a2713aSLionel Sambuc     } a;
884f4a2713aSLionel Sambuc   } foo;
885f4a2713aSLionel Sambuc 
func(T)886f4a2713aSLionel Sambuc   template <typename T> void func(T) {}
test()887f4a2713aSLionel Sambuc   void test() { func(foo().a); }
888f4a2713aSLionel Sambuc }
889f4a2713aSLionel Sambuc 
890f4a2713aSLionel Sambuc namespace test39 {
891f4a2713aSLionel Sambuc   // CHECK-LABEL: define internal void @"_ZN6test394funcINS_3$_03$_1EEEvT_"
892f4a2713aSLionel Sambuc   typedef struct {
893f4a2713aSLionel Sambuc     struct {} a;
894f4a2713aSLionel Sambuc   } *foo;
func(T)895f4a2713aSLionel Sambuc   template<typename T> void func(T) {}
test(foo x)896f4a2713aSLionel Sambuc   void test(foo x) {
897f4a2713aSLionel Sambuc     func(x->a);
898f4a2713aSLionel Sambuc   }
899f4a2713aSLionel Sambuc }
900f4a2713aSLionel Sambuc 
901f4a2713aSLionel Sambuc namespace test40 {
902*0a6a1f1dSLionel Sambuc   // CHECK: i32* {{.*}} @_ZZN6test401fEvE1a_0
903f4a2713aSLionel Sambuc   void h(int&);
f()904f4a2713aSLionel Sambuc   inline void f() {
905f4a2713aSLionel Sambuc     if (0) {
906f4a2713aSLionel Sambuc       static int a;
907f4a2713aSLionel Sambuc     }
908f4a2713aSLionel Sambuc     static int a;
909f4a2713aSLionel Sambuc     h(a);
910f4a2713aSLionel Sambuc   };
g()911f4a2713aSLionel Sambuc   void g() { f(); }
912f4a2713aSLionel Sambuc }
913f4a2713aSLionel Sambuc 
914f4a2713aSLionel Sambuc namespace test41 {
915f4a2713aSLionel Sambuc   // CHECK: define linkonce_odr void @_ZN6test414funcINS_1XEEEvNS_3fooILi20ES1_EE
916f4a2713aSLionel Sambuc   template <int i, class T> struct foo {
func(foo x)917f4a2713aSLionel Sambuc     template <class T2 = T> friend void func(foo x) {}
918f4a2713aSLionel Sambuc   };
919f4a2713aSLionel Sambuc 
920f4a2713aSLionel Sambuc   struct X {};
921f4a2713aSLionel Sambuc 
g()922f4a2713aSLionel Sambuc   void g() { func(foo<20, X>()); }
923f4a2713aSLionel Sambuc }
924f4a2713aSLionel Sambuc 
925f4a2713aSLionel Sambuc namespace test42 {
926f4a2713aSLionel Sambuc   // CHECK: define linkonce_odr void @_ZN6test424funcINS_1XEEEvNS_3fooILi20ES1_EE
927f4a2713aSLionel Sambuc   template <int i, template <class> class T> struct foo {
func(foo x)928f4a2713aSLionel Sambuc     template <template <class> class T2 = T> friend void func(foo x) {}
929f4a2713aSLionel Sambuc   };
930f4a2713aSLionel Sambuc 
931f4a2713aSLionel Sambuc   template <class V> struct X {
932f4a2713aSLionel Sambuc   };
933f4a2713aSLionel Sambuc 
g()934f4a2713aSLionel Sambuc   void g() { func(foo<20, X>()); }
935f4a2713aSLionel Sambuc }
936f4a2713aSLionel Sambuc 
937f4a2713aSLionel Sambuc namespace test43 {
938f4a2713aSLionel Sambuc   // CHECK-LABEL: define void @_ZN6test431gEPNS_3zedIXadL_ZNS_3fooUt_3barEEEEE
939f4a2713aSLionel Sambuc   struct foo { union { int bar; }; };
940f4a2713aSLionel Sambuc   template <int (foo::*)>
941f4a2713aSLionel Sambuc   struct zed {};
g(zed<& foo::bar> *)942f4a2713aSLionel Sambuc   void g(zed<&foo::bar>*)
943f4a2713aSLionel Sambuc   {}
944f4a2713aSLionel Sambuc }
945f4a2713aSLionel Sambuc 
946f4a2713aSLionel Sambuc namespace test44 {
bartest44::foo947f4a2713aSLionel Sambuc   struct foo { void bar() __restrict { }; } obj;
948f4a2713aSLionel Sambuc 
f()949f4a2713aSLionel Sambuc   void f() {
950f4a2713aSLionel Sambuc     obj.bar();
951f4a2713aSLionel Sambuc   }
952f4a2713aSLionel Sambuc   // CHECK-LABEL: define linkonce_odr void @_ZN6test443foo3barEv(%"struct.test44::foo"* %this)
953f4a2713aSLionel Sambuc }
954*0a6a1f1dSLionel Sambuc 
955*0a6a1f1dSLionel Sambuc namespace test45 {
956*0a6a1f1dSLionel Sambuc   struct S {
957*0a6a1f1dSLionel Sambuc     enum e {};
958*0a6a1f1dSLionel Sambuc   };
959*0a6a1f1dSLionel Sambuc   template <typename T>
f(enum T::e *)960*0a6a1f1dSLionel Sambuc   void f(enum T::e *) {}
961*0a6a1f1dSLionel Sambuc   template void f<S>(S::e *);
962*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test451fINS_1SEEEvPTeNT_1eE(i32*)
963*0a6a1f1dSLionel Sambuc }
964*0a6a1f1dSLionel Sambuc 
965*0a6a1f1dSLionel Sambuc namespace test46 {
966*0a6a1f1dSLionel Sambuc   struct S {
967*0a6a1f1dSLionel Sambuc     struct s {};
968*0a6a1f1dSLionel Sambuc   };
969*0a6a1f1dSLionel Sambuc   template <typename T>
f(struct T::s *)970*0a6a1f1dSLionel Sambuc   void f(struct T::s *) {}
971*0a6a1f1dSLionel Sambuc   template void f<S>(S::s *);
972*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test461fINS_1SEEEvPTsNT_1sE(%"struct.test46::S::s"*)
973*0a6a1f1dSLionel Sambuc }
974*0a6a1f1dSLionel Sambuc 
975*0a6a1f1dSLionel Sambuc namespace test47 {
976*0a6a1f1dSLionel Sambuc   struct S {
977*0a6a1f1dSLionel Sambuc     class c {};
978*0a6a1f1dSLionel Sambuc   };
979*0a6a1f1dSLionel Sambuc   template <typename T>
f(class T::c *)980*0a6a1f1dSLionel Sambuc   void f(class T::c *) {}
981*0a6a1f1dSLionel Sambuc   template void f<S>(S::c *);
982*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test471fINS_1SEEEvPTsNT_1cE(%"class.test47::S::c"*)
983*0a6a1f1dSLionel Sambuc }
984*0a6a1f1dSLionel Sambuc 
985*0a6a1f1dSLionel Sambuc namespace test48 {
986*0a6a1f1dSLionel Sambuc   struct S {
987*0a6a1f1dSLionel Sambuc     union u {};
988*0a6a1f1dSLionel Sambuc   };
989*0a6a1f1dSLionel Sambuc   template <typename T>
f(union T::u *)990*0a6a1f1dSLionel Sambuc   void f(union T::u *) {}
991*0a6a1f1dSLionel Sambuc   template void f<S>(S::u *);
992*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: define weak_odr void @_ZN6test481fINS_1SEEEvPTuNT_1uE(%"union.test48::S::u"*)
993*0a6a1f1dSLionel Sambuc }
994*0a6a1f1dSLionel Sambuc 
995*0a6a1f1dSLionel Sambuc namespace test49 {
996*0a6a1f1dSLionel Sambuc   template <int>
997*0a6a1f1dSLionel Sambuc   struct S {};
998*0a6a1f1dSLionel Sambuc 
999*0a6a1f1dSLionel Sambuc   template <template <int> class T>
1000*0a6a1f1dSLionel Sambuc   T<3> fin(T<3>);
1001*0a6a1f1dSLionel Sambuc 
1002*0a6a1f1dSLionel Sambuc   auto v = fin<S>;
1003*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: declare void @_ZN6test493finINS_1SEEET_ILi3EES3_()
1004*0a6a1f1dSLionel Sambuc }
1005*0a6a1f1dSLionel Sambuc 
1006*0a6a1f1dSLionel Sambuc namespace test50 {
1007*0a6a1f1dSLionel Sambuc   template <int>
1008*0a6a1f1dSLionel Sambuc   struct S {};
1009*0a6a1f1dSLionel Sambuc 
1010*0a6a1f1dSLionel Sambuc   template <template <int> class T>
1011*0a6a1f1dSLionel Sambuc   T<3> fin(T<4>);
1012*0a6a1f1dSLionel Sambuc 
1013*0a6a1f1dSLionel Sambuc   auto v = fin<S>;
1014*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: declare void @_ZN6test503finINS_1SEEET_ILi3EES2_ILi4EE()
1015*0a6a1f1dSLionel Sambuc }
1016