Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/func_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,16 @@ indicated routine has just been processed.
a_boolean needed = FALSE;
a_type_ptr class_type = parent_class_of(routine);

#if IA64_ABI && ABI_COMPATIBILITY_VERSION >= 410
if (is_unspecialized_template_class(class_type) &&
class_type->variant.class_struct_union.do_not_instantiate &&
!class_type->variant.class_struct_union.explicitly_instantiated &&
class_type->source_corresp.name_linkage == nlk_cplusplus_external &&
!class_type_supp(class_type)->named_in_inline_template_directive) {
/* Lowering suppresses this specialization's virtual function table. */
} else
#endif /* IA64_ABI && ABI_COMPATIBILITY_VERSION >= 410 */
/* Do not insert code here. */
if (class_type->variant.class_struct_union.
any_virtual_functions_including_in_base_classes) {
if (routine->special_kind == (a_special_function_kind)sfk_constructor ||
Expand Down
18 changes: 18 additions & 0 deletions src/pending_changes/gh-431.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[GH #431]
Virtual function instantiation for suppressed class template specializations

Previously, in IA-64 ABI configurations with ABI_COMPATIBILITY_VERSION >= 410,
defining an inline member function of a class template specialization whose
instantiation was suppressed could unnecessarily instantiate the class's
virtual functions. This no longer occurs when the specialization has external
linkage and its virtual function table is suppressed. A GNU "inline template"
directive still requires the virtual functions. For example, with
--c++11 -tused:

template<int N> struct C {
virtual void f() {
static_assert(N != 1, ""); // Previously a spurious error, now okay.
}
};
extern template class C<1>;
C<1> c;
127 changes: 127 additions & 0 deletions tests/tests/regressions/.gh-431-diag.rto/default.1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
fe_only -DTEST_NUMBER=1 -tused --c++11 Test_name.c
"Test_name.c", line 11: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 11: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_call::C<T>::f() [with T=int]" at line 20

"Test_name.c", line 33: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 33: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_call_inline_out_of_class::C<T>::f() [with T=int]" at line 40

"Test_name.c", line 50: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 50: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation::C<T>::f() [with T=int]" at line 56

"Test_name.c", line 84: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 84: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation_inline_out_of_class::C<T>::f() [with T=int]" at line 88

"Test_name.c", line 223: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 223: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_virtual_call::C<T>::f() [with T=int]" at line 232

"Test_name.c", line 245: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 245: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_virtual_call_inline_out_of_class::C<T>::f() [with T=int]" at line 252

"Test_name.c", line 68: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 68: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation_out_of_class::C<T>::f() [with T=int]" at line 72

"Test_name.c", line 97: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 97: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void derived_vtable::C<T>::f() [with T=int]"

"Test_name.c", line 121: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 121: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void derived_vtable_inline_out_of_class::C<T>::f() [with T=int]"

"Test_name.c", line 145: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 145: note: the final comparison was 1 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage::C<T>::f() [with T=internal_linkage::<unnamed>::Local]"

"Test_name.c", line 168: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 168: note: the final comparison was 1 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage_inline_out_of_class::C<T>::f() [with T=internal_linkage_inline_out_of_class::<unnamed>::Local]"

"Test_name.c", line 183: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 183: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage_template::<unnamed>::C<T>::f() [with T=int]"

"Test_name.c", line 207: error: static assertion failed with ""
static_assert(P == nullptr, "");
^
detected during instantiation of "void internal_linkage_nontype_argument::C<P>::f() [with P=&internal_linkage_nontype_argument::value]"

"Test_name.c", line 262: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 262: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void specialized_nested_class::Base<T>::f() [with T=int]"

"Test_name.c", line 287: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 287: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void nontemplate_nested_class::Base<T>::f() [with T=int]"

"Test_name.c", line 314: error: static assertion failed with ""
static_assert(N != 2, "");
^
"Test_name.c", line 314: note: the final comparison was 2 != 2
static_assert(N != 2, "");
^
detected during instantiation of "void unsuppressed_specialization::C<N>::f() [with N=2]"

16 errors detected in the compilation of "Test_name.c".
143 changes: 143 additions & 0 deletions tests/tests/regressions/.gh-431-diag.rto/default.2.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
fe_only -DTEST_NUMBER=2 -tused --gnu_version 150200 Test_name.c
"Test_name.c", line 11: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 11: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_call::C<T>::f() [with T=int]" at line 20

"Test_name.c", line 33: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 33: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_call_inline_out_of_class::C<T>::f() [with T=int]" at line 40

"Test_name.c", line 50: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 50: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation::C<T>::f() [with T=int]" at line 56

"Test_name.c", line 68: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 68: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation_out_of_class::C<T>::f() [with T=int]" at line 72

"Test_name.c", line 84: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 84: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void explicit_instantiation_inline_out_of_class::C<T>::f() [with T=int]" at line 88

"Test_name.c", line 97: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 97: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void derived_vtable::C<T>::f() [with T=int]"

"Test_name.c", line 121: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 121: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void derived_vtable_inline_out_of_class::C<T>::f() [with T=int]"

"Test_name.c", line 145: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 145: note: the final comparison was 1 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage::C<T>::f() [with T=internal_linkage::<unnamed>::Local]"

"Test_name.c", line 168: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 168: note: the final comparison was 1 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage_inline_out_of_class::C<T>::f() [with T=internal_linkage_inline_out_of_class::<unnamed>::Local]"

"Test_name.c", line 183: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 183: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void internal_linkage_template::<unnamed>::C<T>::f() [with T=int]"

"Test_name.c", line 207: error: static assertion failed with ""
static_assert(P == nullptr, "");
^
detected during instantiation of "void internal_linkage_nontype_argument::C<P>::f() [with P=&internal_linkage_nontype_argument::value]"

"Test_name.c", line 223: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 223: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_virtual_call::C<T>::f() [with T=int]" at line 232

"Test_name.c", line 245: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 245: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void direct_virtual_call_inline_out_of_class::C<T>::f() [with T=int]" at line 252

"Test_name.c", line 262: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 262: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void specialized_nested_class::Base<T>::f() [with T=int]"

"Test_name.c", line 287: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 287: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void nontemplate_nested_class::Base<T>::f() [with T=int]"

"Test_name.c", line 314: error: static assertion failed with ""
static_assert(N != 2, "");
^
"Test_name.c", line 314: note: the final comparison was 2 != 2
static_assert(N != 2, "");
^
detected during instantiation of "void unsuppressed_specialization::C<N>::f() [with N=2]"

"Test_name.c", line 331: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 331: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void inline_template::C<T>::f() [with T=int]"

"Test_name.c", line 349: error: static assertion failed with ""
static_assert(sizeof(T) == 0, "");
^
"Test_name.c", line 349: note: the final comparison was 4 == 0
static_assert(sizeof(T) == 0, "");
^
detected during instantiation of "void inline_template_inline_out_of_class::C<T>::f() [with T=int]"

18 errors detected in the compilation of "Test_name.c".
Loading
Loading