2010-03-14 02:23:07 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s
|
2009-05-27 04:50:29 +08:00
|
|
|
|
2010-08-25 16:27:02 +08:00
|
|
|
// This check logically is attached to 'template int S<int>::i;' below.
|
2011-04-12 09:46:54 +08:00
|
|
|
// CHECK: @_ZN1SIiE1iE = weak_odr global i32
|
2010-08-25 16:27:02 +08:00
|
|
|
|
2009-05-27 04:50:29 +08:00
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
struct plus {
|
2009-09-05 06:48:11 +08:00
|
|
|
Result operator()(const T& t, const U& u) const;
|
2009-05-27 04:50:29 +08:00
|
|
|
};
|
|
|
|
|
2009-09-05 06:48:11 +08:00
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
Result plus<T, U, Result>::operator()(const T& t, const U& u) const {
|
|
|
|
return t + u;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr i32 @_ZNK4plusIillEclERKiRKl
|
2009-05-27 04:50:29 +08:00
|
|
|
template struct plus<int, long, long>;
|
2010-08-25 16:27:02 +08:00
|
|
|
|
|
|
|
// Check that we emit definitions from explicit instantiations even when they
|
|
|
|
// occur prior to the definition itself.
|
|
|
|
template <typename T> struct S {
|
|
|
|
void f();
|
|
|
|
static void g();
|
|
|
|
static int i;
|
|
|
|
struct S2 {
|
|
|
|
void h();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_ZN1SIiE1fEv
|
2010-08-25 16:27:02 +08:00
|
|
|
template void S<int>::f();
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_ZN1SIiE1gEv
|
2010-08-25 16:27:02 +08:00
|
|
|
template void S<int>::g();
|
|
|
|
|
|
|
|
// See the check line at the top of the file.
|
|
|
|
template int S<int>::i;
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_ZN1SIiE2S21hEv
|
2010-08-25 16:27:02 +08:00
|
|
|
template void S<int>::S2::h();
|
|
|
|
|
|
|
|
template <typename T> void S<T>::f() {}
|
|
|
|
template <typename T> void S<T>::g() {}
|
|
|
|
template <typename T> int S<T>::i;
|
|
|
|
template <typename T> void S<T>::S2::h() {}
|