Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 2 | |
Chandler Carruth | 58e390e | 2010-08-25 08:27:02 +0000 | [diff] [blame] | 3 | // This check logically is attached to 'template int S<int>::i;' below. |
| 4 | // CHECK: @_ZN1SIiE1iE = weak global i32 |
| 5 | |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 6 | template<typename T, typename U, typename Result> |
| 7 | struct plus { |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 8 | Result operator()(const T& t, const U& u) const; |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 9 | }; |
| 10 | |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 11 | template<typename T, typename U, typename Result> |
| 12 | Result plus<T, U, Result>::operator()(const T& t, const U& u) const { |
| 13 | return t + u; |
| 14 | } |
| 15 | |
Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 16 | // CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl |
Douglas Gregor | aba43bb | 2009-05-26 20:50:29 +0000 | [diff] [blame] | 17 | template struct plus<int, long, long>; |
Chandler Carruth | 58e390e | 2010-08-25 08:27:02 +0000 | [diff] [blame] | 18 | |
| 19 | // Check that we emit definitions from explicit instantiations even when they |
| 20 | // occur prior to the definition itself. |
| 21 | template <typename T> struct S { |
| 22 | void f(); |
| 23 | static void g(); |
| 24 | static int i; |
| 25 | struct S2 { |
| 26 | void h(); |
| 27 | }; |
| 28 | }; |
| 29 | |
| 30 | // CHECK: define weak_odr void @_ZN1SIiE1fEv |
| 31 | template void S<int>::f(); |
| 32 | |
| 33 | // CHECK: define weak_odr void @_ZN1SIiE1gEv |
| 34 | template void S<int>::g(); |
| 35 | |
| 36 | // See the check line at the top of the file. |
| 37 | template int S<int>::i; |
| 38 | |
| 39 | // CHECK: define weak_odr void @_ZN1SIiE2S21hEv |
| 40 | template void S<int>::S2::h(); |
| 41 | |
| 42 | template <typename T> void S<T>::f() {} |
| 43 | template <typename T> void S<T>::g() {} |
| 44 | template <typename T> int S<T>::i; |
| 45 | template <typename T> void S<T>::S2::h() {} |