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