]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Non-inline temploid friends should still be COMDAT [PR122819]
authorNathaniel Shead <nathanieloshead@gmail.com>
Sun, 7 Dec 2025 12:17:15 +0000 (23:17 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Tue, 9 Dec 2025 02:38:23 +0000 (13:38 +1100)
commitcf22e30f0cfae65dd012966cab657583e2be667e
treee6f00d76220c4783e92ec55223d1348b4aef3fcd
parent8be2b7797769e48ab2c0adccdfef1c922cb343bc
c++: Non-inline temploid friends should still be COMDAT [PR122819]

Modules allow temploid friends to no longer be implicitly inline, as
functions defined in a class body will not be implicitly inline if
attached to a named module.

This requires us to clean up linkage handling a little bit, mostly by
replacing usages of 'DECL_TEMPLATE_INSTANTIATION' with
'DECL_TEMPLOID_INSTANTIATION' when determining if an entity has vague
linkage.

PR c++/122819

gcc/cp/ChangeLog:

* decl.cc (start_preparsed_function): Use
DECL_TEMPLOID_INSTANTIATION instead of
DECL_TEMPLATE_INSTANTIATION to check vague linkage.
* decl2.cc (vague_linkage_p): Likewise.
(c_parse_final_cleanups): Simplify condition.
* semantics.cc (expand_or_defer_fn_1): Also check for temploid
friend functions.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tpl-friend-22.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/decl.cc
gcc/cp/decl2.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/modules/tpl-friend-22.C [new file with mode: 0644]