blob: 416c0a1a20729edd6279aa9195efbbdff9e08045 [file] [log] [blame]
Rafael Espindolaf3eaf452010-03-24 22:43:31 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
Rafael Espindolae0f38672010-03-30 18:07:27 +00004// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
Rafael Espindolaf3eaf452010-03-24 22:43:31 +00005// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
6
7// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(
8// CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
9// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd(
10
11namespace test0 {
12 struct basic_streambuf {
13 virtual ~basic_streambuf();
14 };
15 template<typename _CharT >
16 struct stdio_sync_filebuf : public basic_streambuf {
17 virtual void xsgetn();
18 };
19
20 // This specialization should cause the vtable to be emitted, even with
21 // the following extern template declaration.
22 template<> void stdio_sync_filebuf<wchar_t>::xsgetn() {
23 }
24 extern template class stdio_sync_filebuf<wchar_t>;
25}
26
27namespace test1 {
28 struct basic_streambuf {
29 virtual ~basic_streambuf();
30 };
31 template<typename _CharT >
32 struct stdio_sync_filebuf : public basic_streambuf {
33 virtual void xsgetn();
34 };
35
36 // Just a declaration should not force the vtable to be emitted.
37 template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
38}
39
40namespace test2 {
41 template<typename T1>
42 class C {
43 virtual ~C();
44 void zedbar(double) {
45 }
46 template<typename T2>
47 void foobar(T2 foo) {
48 }
49 };
50 extern template class C<int>;
51 void g() {
52 // The extern template declaration should not prevent us from producing
53 // the implicit constructor (test at the top).
54 C<int> a;
55
56 // or foobar(test at the top).
57 a.foobar(0.0);
58
59 // But it should prevent zebbar
60 // (test at the top).
61 a.zedbar(0.0);
62 }
63}
Rafael Espindolae0f38672010-03-30 18:07:27 +000064
65namespace test3 {
66 template<typename T>
67 class basic_fstreamXX {
68 virtual void foo(){}
69 virtual void is_open() const { }
70 };
71
72 extern template class basic_fstreamXX<char>;
73 // This template instantiation should not cause us to produce a vtable.
74 // (test at the top).
75 template void basic_fstreamXX<char>::is_open() const;
76}