blob: 4a3857542d06d220dc94259d0a8dd41a6b2a5119 [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 {
John McCall7002f4c2010-04-09 19:03:51 +000043 public:
Rafael Espindolaf3eaf452010-03-24 22:43:31 +000044 virtual ~C();
45 void zedbar(double) {
46 }
47 template<typename T2>
48 void foobar(T2 foo) {
49 }
50 };
51 extern template class C<int>;
52 void g() {
53 // The extern template declaration should not prevent us from producing
54 // the implicit constructor (test at the top).
55 C<int> a;
56
57 // or foobar(test at the top).
58 a.foobar(0.0);
59
60 // But it should prevent zebbar
61 // (test at the top).
62 a.zedbar(0.0);
63 }
64}
Rafael Espindolae0f38672010-03-30 18:07:27 +000065
66namespace test3 {
67 template<typename T>
68 class basic_fstreamXX {
69 virtual void foo(){}
70 virtual void is_open() const { }
71 };
72
73 extern template class basic_fstreamXX<char>;
74 // This template instantiation should not cause us to produce a vtable.
75 // (test at the top).
76 template void basic_fstreamXX<char>::is_open() const;
77}