Hans Wennborg | c9bd88e | 2014-01-14 19:35:09 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - | FileCheck %s |
David Majnemer | 9963ade | 2014-12-16 04:52:14 +0000 | [diff] [blame] | 2 | |
| 3 | // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i = internal global i32 4 |
| 4 | // CHECK-DAG: _ZZN7PR219047GetDataIiEERKibE1i_0 = internal global i32 2 |
| 5 | |
Douglas Gregor | 8f5d442 | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 6 | template<typename T, typename U> |
| 7 | T* next(T* ptr, const U& diff); |
| 8 | |
| 9 | template<typename T, typename U> |
| 10 | T* next(T* ptr, const U& diff) { |
| 11 | return ptr + diff; |
| 12 | } |
| 13 | |
| 14 | void test(int *iptr, float *fptr, int diff) { |
Anders Carlsson | a2fb9bc | 2009-09-17 04:02:31 +0000 | [diff] [blame] | 15 | // CHECK: _Z4nextIiiEPT_S1_RKT0_ |
Douglas Gregor | 8f5d442 | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 16 | iptr = next(iptr, diff); |
Anders Carlsson | a2fb9bc | 2009-09-17 04:02:31 +0000 | [diff] [blame] | 17 | |
| 18 | // CHECK: _Z4nextIfiEPT_S1_RKT0_ |
Douglas Gregor | 8f5d442 | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 19 | fptr = next(fptr, diff); |
| 20 | } |
| 21 | |
| 22 | template<typename T, typename U> |
| 23 | T* next(T* ptr, const U& diff); |
| 24 | |
| 25 | void test2(int *iptr, double *dptr, int diff) { |
| 26 | iptr = next(iptr, diff); |
Anders Carlsson | a2fb9bc | 2009-09-17 04:02:31 +0000 | [diff] [blame] | 27 | |
| 28 | // CHECK: _Z4nextIdiEPT_S1_RKT0_ |
Douglas Gregor | 8f5d442 | 2009-06-29 20:59:39 +0000 | [diff] [blame] | 29 | dptr = next(dptr, diff); |
Owen Anderson | e05f2ed | 2009-07-27 21:00:51 +0000 | [diff] [blame] | 30 | } |
David Majnemer | 9963ade | 2014-12-16 04:52:14 +0000 | [diff] [blame] | 31 | |
| 32 | namespace PR21904 { |
| 33 | template <typename> |
| 34 | const int &GetData(bool); |
| 35 | |
| 36 | template <> |
| 37 | const 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 | } |