blob: 8daf3c6800068fe70d8dc03ebb2a9e2c0e20159b [file] [log] [blame]
Douglas Gregor8f51a4f2010-03-13 18:23:07 +00001// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s
Douglas Gregoraba43bb2009-05-26 20:50:29 +00002
Chandler Carruth58e390e2010-08-25 08:27:02 +00003// This check logically is attached to 'template int S<int>::i;' below.
John McCall99ace162011-04-12 01:46:54 +00004// CHECK: @_ZN1SIiE1iE = weak_odr global i32
Chandler Carruth58e390e2010-08-25 08:27:02 +00005
Douglas Gregoraba43bb2009-05-26 20:50:29 +00006template<typename T, typename U, typename Result>
7struct plus {
Douglas Gregord0e3daf2009-09-04 22:48:11 +00008 Result operator()(const T& t, const U& u) const;
Douglas Gregoraba43bb2009-05-26 20:50:29 +00009};
10
Douglas Gregord0e3daf2009-09-04 22:48:11 +000011template<typename T, typename U, typename Result>
12Result plus<T, U, Result>::operator()(const T& t, const U& u) const {
13 return t + u;
14}
15
Douglas Gregor8f51a4f2010-03-13 18:23:07 +000016// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl
Douglas Gregoraba43bb2009-05-26 20:50:29 +000017template struct plus<int, long, long>;
Chandler Carruth58e390e2010-08-25 08:27:02 +000018
19// Check that we emit definitions from explicit instantiations even when they
20// occur prior to the definition itself.
21template <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
31template void S<int>::f();
32
33// CHECK: define weak_odr void @_ZN1SIiE1gEv
34template void S<int>::g();
35
36// See the check line at the top of the file.
37template int S<int>::i;
38
39// CHECK: define weak_odr void @_ZN1SIiE2S21hEv
40template void S<int>::S2::h();
41
42template <typename T> void S<T>::f() {}
43template <typename T> void S<T>::g() {}
44template <typename T> int S<T>::i;
45template <typename T> void S<T>::S2::h() {}