1// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s
2
3// This check logically is attached to 'template int S<int>::i;' below.
4// CHECK: @_ZN1SIiE1iE = weak_odr global i32
5
6template<typename T, typename U, typename Result>
7struct plus {
8  Result operator()(const T& t, const U& u) const;
9};
10
11template<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
16// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl
17template struct plus<int, long, long>;
18
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() {}
46