diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/CodeGenCXX/explicit-instantiation.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/CodeGenCXX/explicit-instantiation.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/explicit-instantiation.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/explicit-instantiation.cpp b/clang/test/CodeGenCXX/explicit-instantiation.cpp new file mode 100644 index 0000000..8daf3c6 --- /dev/null +++ b/clang/test/CodeGenCXX/explicit-instantiation.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s + +// This check logically is attached to 'template int S<int>::i;' below. +// CHECK: @_ZN1SIiE1iE = weak_odr global i32 + +template<typename T, typename U, typename Result> +struct plus { + Result operator()(const T& t, const U& u) const; +}; + +template<typename T, typename U, typename Result> +Result plus<T, U, Result>::operator()(const T& t, const U& u) const { + return t + u; +} + +// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl +template struct plus<int, long, long>; + +// 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() {} |