Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
Nick Lewycky | f91cbd5 | 2013-01-10 01:46:29 +0000 | [diff] [blame] | 2 | |
| 3 | // CHECK: Outer5Inner{{.*}}localE6memberE = external global |
| 4 | |
Anders Carlsson | 548e60e | 2009-12-10 22:25:34 +0000 | [diff] [blame] | 5 | template<typename T> struct A { |
| 6 | virtual void f(T) { } |
| 7 | inline void g() { } |
| 8 | }; |
| 9 | |
| 10 | // Explicit instantiations have external linkage. |
| 11 | |
Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 12 | // CHECK: define weak_odr void @_ZN1AIiE1gEv( |
Anders Carlsson | 548e60e | 2009-12-10 22:25:34 +0000 | [diff] [blame] | 13 | template void A<int>::g(); |
| 14 | |
Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 15 | // CHECK: define weak_odr void @_ZN1AIfE1fEf( |
| 16 | // CHECK: define weak_odr void @_ZN1AIfE1gEv( |
Anders Carlsson | 548e60e | 2009-12-10 22:25:34 +0000 | [diff] [blame] | 17 | // FIXME: This should also emit the vtable. |
| 18 | template struct A<float>; |
| 19 | |
Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 20 | // CHECK: define weak_odr void @_Z1fIiEvT_ |
Anders Carlsson | 548e60e | 2009-12-10 22:25:34 +0000 | [diff] [blame] | 21 | template <typename T> void f(T) { } |
| 22 | template void f<int>(int); |
| 23 | |
Douglas Gregor | 8f51a4f | 2010-03-13 18:23:07 +0000 | [diff] [blame] | 24 | // CHECK: define weak_odr void @_Z1gIiEvT_ |
Anders Carlsson | 548e60e | 2009-12-10 22:25:34 +0000 | [diff] [blame] | 25 | template <typename T> inline void g(T) { } |
| 26 | template void g<int>(int); |
| 27 | |
Douglas Gregor | b076910 | 2010-05-06 23:13:35 +0000 | [diff] [blame] | 28 | template<typename T> |
| 29 | struct X0 { |
| 30 | virtual ~X0() { } |
| 31 | }; |
| 32 | |
| 33 | template<typename T> |
| 34 | struct X1 : X0<T> { |
| 35 | virtual void blarg(); |
| 36 | }; |
| 37 | |
| 38 | template<typename T> void X1<T>::blarg() { } |
| 39 | |
| 40 | extern template struct X0<char>; |
| 41 | extern template struct X1<char>; |
| 42 | |
Rafael Espindola | 0691a5c | 2011-01-25 19:10:24 +0000 | [diff] [blame] | 43 | // CHECK: define linkonce_odr void @_ZN2X1IcED1Ev(%struct.X1* %this) unnamed_addr |
Douglas Gregor | b076910 | 2010-05-06 23:13:35 +0000 | [diff] [blame] | 44 | void test_X1() { |
| 45 | X1<char> i1c; |
| 46 | } |
| 47 | |
Nick Lewycky | f91cbd5 | 2013-01-10 01:46:29 +0000 | [diff] [blame] | 48 | namespace PR14825 { |
| 49 | struct Outer { |
| 50 | template <typename T> struct Inner { |
| 51 | static int member; |
| 52 | }; |
| 53 | template <typename T> void Get() { |
| 54 | int m = Inner<T>::member; |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | void test() { |
| 59 | struct local {}; |
| 60 | Outer o; |
| 61 | typedef void (Outer::*mptr)(); |
| 62 | mptr method = &Outer::Get<local>; |
| 63 | } |
| 64 | } |