summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/vtable-linkage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenCXX/vtable-linkage.cpp')
-rw-r--r--test/CodeGenCXX/vtable-linkage.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/test/CodeGenCXX/vtable-linkage.cpp b/test/CodeGenCXX/vtable-linkage.cpp
index 6d3cf24..63e17431 100644
--- a/test/CodeGenCXX/vtable-linkage.cpp
+++ b/test/CodeGenCXX/vtable-linkage.cpp
@@ -30,6 +30,55 @@ void D::f() { }
static struct : D { } e;
+// The destructor is the key function.
+template<typename T>
+struct E {
+ virtual ~E();
+};
+
+template<typename T> E<T>::~E() { }
+
+// Anchor is the key function
+template<>
+struct E<char> {
+ virtual void anchor();
+};
+
+void E<char>::anchor() { }
+
+template struct E<short>;
+extern template struct E<int>;
+
+void use_E() {
+ E<int> ei;
+ (void)ei;
+ E<long> el;
+ (void)el;
+}
+
+// No key function
+template<typename T>
+struct F {
+ virtual void foo() { }
+};
+
+// No key function
+template<>
+struct F<char> {
+ virtual void foo() { }
+};
+
+template struct F<short>;
+extern template struct F<int>;
+
+void use_F(F<char> &fc) {
+ F<int> fi;
+ (void)fi;
+ F<long> fl;
+ (void)fl;
+ fc.foo();
+}
+
// B has a key function that is not defined in this translation unit so its vtable
// has external linkage.
// CHECK: @_ZTV1B = external constant
@@ -45,6 +94,50 @@ static struct : D { } e;
// CHECK: @_ZTI1D = constant
// CHECK: @_ZTV1D = constant
+// E<char> is an explicit specialization with a key function defined
+// in this translation unit, so its vtable should have external
+// linkage.
+// CHECK: @_ZTS1EIcE = constant
+// CHECK: @_ZTI1EIcE = constant
+// CHECK: @_ZTV1EIcE = constant
+
+// E<short> is an explicit template instantiation with a key function
+// defined in this translation unit, so its vtable should have
+// weak_odr linkage.
+// CHECK: @_ZTS1EIsE = weak_odr constant
+// CHECK: @_ZTI1EIsE = weak_odr constant
+// CHECK: @_ZTV1EIsE = weak_odr constant
+
+// F<short> is an explicit template instantiation without a key
+// function, so its vtable should have weak_odr linkage
+// CHECK: @_ZTS1FIsE = weak_odr constant
+// CHECK: @_ZTI1FIsE = weak_odr constant
+// CHECK: @_ZTV1FIsE = weak_odr constant
+
+// E<long> is an implicit template instantiation with a key function
+// defined in this translation unit, so its vtable should have
+// weak_odr linkage.
+// CHECK: @_ZTS1EIlE = weak_odr constant
+// CHECK: @_ZTI1EIlE = weak_odr constant
+// CHECK: @_ZTV1EIlE = weak_odr constant
+
+// F<long> is an implicit template instantiation with no key function,
+// so its vtable should have weak_odr linkage.
+// CHECK: @_ZTS1FIlE = weak_odr constant
+// CHECK: @_ZTI1FIlE = weak_odr constant
+// CHECK: @_ZTV1FIlE = weak_odr constant
+
+// F<int> is an explicit template instantiation declaration without a
+// key function, so its vtable should have weak_odr linkage.
+// CHECK: @_ZTS1FIiE = weak_odr constant
+// CHECK: @_ZTI1FIiE = weak_odr constant
+// CHECK: @_ZTV1FIiE = weak_odr constant
+
+// E<int> is an explicit template instantiation declaration. It has a
+// key function that is not instantiated, so we should only reference
+// its vtable, not define it.
+// CHECK: @_ZTV1EIiE = external constant
+
// The anonymous struct for e has no linkage, so the vtable should have
// internal linkage.
// CHECK: @"_ZTS3$_0" = internal constant
@@ -56,3 +149,5 @@ static struct : D { } e;
// CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant
// CHECK: @_ZTIN12_GLOBAL__N_11AE = internal constant
// CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant
+
+
OpenPOWER on IntegriCloud