xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/function-template-specialization.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i = internal global i32 4
4*0a6a1f1dSLionel Sambuc // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i_0 = internal global i32 2
5*0a6a1f1dSLionel Sambuc 
6f4a2713aSLionel Sambuc template<typename T, typename U>
7f4a2713aSLionel Sambuc T* next(T* ptr, const U& diff);
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc template<typename T, typename U>
next(T * ptr,const U & diff)10f4a2713aSLionel Sambuc T* next(T* ptr, const U& diff) {
11f4a2713aSLionel Sambuc   return ptr + diff;
12f4a2713aSLionel Sambuc }
13f4a2713aSLionel Sambuc 
test(int * iptr,float * fptr,int diff)14f4a2713aSLionel Sambuc void test(int *iptr, float *fptr, int diff) {
15f4a2713aSLionel Sambuc   // CHECK: _Z4nextIiiEPT_S1_RKT0_
16f4a2713aSLionel Sambuc   iptr = next(iptr, diff);
17f4a2713aSLionel Sambuc 
18f4a2713aSLionel Sambuc   // CHECK: _Z4nextIfiEPT_S1_RKT0_
19f4a2713aSLionel Sambuc   fptr = next(fptr, diff);
20f4a2713aSLionel Sambuc }
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc template<typename T, typename U>
23f4a2713aSLionel Sambuc T* next(T* ptr, const U& diff);
24f4a2713aSLionel Sambuc 
test2(int * iptr,double * dptr,int diff)25f4a2713aSLionel Sambuc void test2(int *iptr, double *dptr, int diff) {
26f4a2713aSLionel Sambuc   iptr = next(iptr, diff);
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc   // CHECK: _Z4nextIdiEPT_S1_RKT0_
29f4a2713aSLionel Sambuc   dptr = next(dptr, diff);
30f4a2713aSLionel Sambuc }
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc namespace PR21904 {
33*0a6a1f1dSLionel Sambuc template <typename>
34*0a6a1f1dSLionel Sambuc const int &GetData(bool);
35*0a6a1f1dSLionel Sambuc 
36*0a6a1f1dSLionel Sambuc template <>
GetData(bool b)37*0a6a1f1dSLionel Sambuc const int &GetData<int>(bool b) {
38*0a6a1f1dSLionel Sambuc   static int i = 4;
39*0a6a1f1dSLionel Sambuc   if (b) {
40*0a6a1f1dSLionel Sambuc     static int i = 2;
41*0a6a1f1dSLionel Sambuc     return i;
42*0a6a1f1dSLionel Sambuc   }
43*0a6a1f1dSLionel Sambuc   return i;
44*0a6a1f1dSLionel Sambuc }
45*0a6a1f1dSLionel Sambuc }
46