blob: 20508c1596fea977ee5b37c5e85f9d941c04122f [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
Anders Carlsson548e60e2009-12-10 22:25:34 +00002template<typename T> struct A {
3 virtual void f(T) { }
4 inline void g() { }
5};
6
7// Explicit instantiations have external linkage.
8
Douglas Gregor8f51a4f2010-03-13 18:23:07 +00009// CHECK: define weak_odr void @_ZN1AIiE1gEv(
Anders Carlsson548e60e2009-12-10 22:25:34 +000010template void A<int>::g();
11
Douglas Gregor8f51a4f2010-03-13 18:23:07 +000012// CHECK: define weak_odr void @_ZN1AIfE1fEf(
13// CHECK: define weak_odr void @_ZN1AIfE1gEv(
Anders Carlsson548e60e2009-12-10 22:25:34 +000014// FIXME: This should also emit the vtable.
15template struct A<float>;
16
Douglas Gregor8f51a4f2010-03-13 18:23:07 +000017// CHECK: define weak_odr void @_Z1fIiEvT_
Anders Carlsson548e60e2009-12-10 22:25:34 +000018template <typename T> void f(T) { }
19template void f<int>(int);
20
Douglas Gregor8f51a4f2010-03-13 18:23:07 +000021// CHECK: define weak_odr void @_Z1gIiEvT_
Anders Carlsson548e60e2009-12-10 22:25:34 +000022template <typename T> inline void g(T) { }
23template void g<int>(int);
24
Douglas Gregorb0769102010-05-06 23:13:35 +000025template<typename T>
26struct X0 {
27 virtual ~X0() { }
28};
29
30template<typename T>
31struct X1 : X0<T> {
32 virtual void blarg();
33};
34
35template<typename T> void X1<T>::blarg() { }
36
37extern template struct X0<char>;
38extern template struct X1<char>;
39
Rafael Espindola0691a5c2011-01-25 19:10:24 +000040// CHECK: define linkonce_odr void @_ZN2X1IcED1Ev(%struct.X1* %this) unnamed_addr
Douglas Gregorb0769102010-05-06 23:13:35 +000041void test_X1() {
42 X1<char> i1c;
43}
44