blob: 29c737c8e9ba799e524e7c8151e26621242a7455 [file] [log] [blame]
Rafael Espindolab0f65ca2010-03-22 23:12:48 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
4// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
5
Rafael Espindola5fb12c62010-03-23 18:56:16 +00006// CHECK: define linkonce_odr void @_ZN5test21CIiE5fobarIdEEvT_
7// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd
8
Rafael Espindolab0f65ca2010-03-22 23:12:48 +00009namespace test0 {
10 struct basic_streambuf {
11 virtual ~basic_streambuf();
12 };
13 template<typename _CharT >
14 struct stdio_sync_filebuf : public basic_streambuf {
15 virtual void xsgetn();
16 };
17
18 // This specialization should cause the vtable to be emitted, even with
Rafael Espindola5fb12c62010-03-23 18:56:16 +000019 // the following extern template declaration (test at the top).
20
21 // The existance of the extern template declaration should prevent us from emitting
22 // destructors.
23 // CHECK: define available_externally void @_ZN5test018stdio_sync_filebufIwED0Ev
24 // CHECK: define available_externally void @_ZN5test018stdio_sync_filebufIwED2Ev
Rafael Espindolab0f65ca2010-03-22 23:12:48 +000025 template<> void stdio_sync_filebuf<wchar_t>::xsgetn() {
26 }
27 extern template class stdio_sync_filebuf<wchar_t>;
28}
29
30namespace test1 {
31 struct basic_streambuf {
32 virtual ~basic_streambuf();
33 };
34 template<typename _CharT >
35 struct stdio_sync_filebuf : public basic_streambuf {
36 virtual void xsgetn();
37 };
38
Rafael Espindola5fb12c62010-03-23 18:56:16 +000039 // Just a declaration should not force the vtable to be emitted
40 // (test at the top).
Rafael Espindolab0f65ca2010-03-22 23:12:48 +000041 template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
42}
Rafael Espindola5fb12c62010-03-23 18:56:16 +000043
44namespace test2 {
45 template<typename T1>
46 class C {
47 void zedbar(double) {
48 }
49 template<typename T2>
50 void fobar(T2 foo) {
51 }
52 };
53 extern template class C<int>;
54 void g() {
55 C<int> a;
56 // The extern template declaration should not prevent us from producing
57 /// foobar.
58 // (test at the top).
59 a.fobar(0.0);
60
61 // But it should prevent zebbar
62 // (test at the top).
63 a.zedbar(0.0);
64 }
65}