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