2010-03-13 21:23:07 +03:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s
|
2009-05-27 00:50:29 +04:00
|
|
|
|
2010-08-25 12:27:02 +04:00
|
|
|
// This check logically is attached to 'template int S<int>::i;' below.
|
2011-04-12 05:46:54 +04:00
|
|
|
// CHECK: @_ZN1SIiE1iE = weak_odr global i32
|
2010-08-25 12:27:02 +04:00
|
|
|
|
2009-05-27 00:50:29 +04:00
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
struct plus {
|
2009-09-05 02:48:11 +04:00
|
|
|
Result operator()(const T& t, const U& u) const;
|
2009-05-27 00:50:29 +04:00
|
|
|
};
|
|
|
|
|
2009-09-05 02:48:11 +04:00
|
|
|
template<typename T, typename U, typename Result>
|
|
|
|
Result plus<T, U, Result>::operator()(const T& t, const U& u) const {
|
|
|
|
return t + u;
|
|
|
|
}
|
|
|
|
|
2010-03-13 21:23:07 +03:00
|
|
|
// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl
|
2009-05-27 00:50:29 +04:00
|
|
|
template struct plus<int, long, long>;
|
2010-08-25 12:27:02 +04: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();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: define weak_odr void @_ZN1SIiE1fEv
|
|
|
|
template void S<int>::f();
|
|
|
|
|
|
|
|
// CHECK: define weak_odr void @_ZN1SIiE1gEv
|
|
|
|
template void S<int>::g();
|
|
|
|
|
|
|
|
// See the check line at the top of the file.
|
|
|
|
template int S<int>::i;
|
|
|
|
|
|
|
|
// CHECK: define weak_odr void @_ZN1SIiE2S21hEv
|
|
|
|
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() {}
|