]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]
authorNathaniel Shead <nathanieloshead@gmail.com>
Thu, 8 May 2025 13:06:13 +0000 (23:06 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 14 May 2025 09:26:24 +0000 (19:26 +1000)
commitd787bc4fd372298e9ed5b11cb3050fd3707070f6
treea5a3cd1e9980a78ca8214967c73c5e69a788af84
parent79b7e37ea3fbbc43958190f69f6da3be3d809c9c
c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]

The attached testcase ICEs in maybe_thunk_body because we haven't
created a node in the cgraph for an imported explicit instantiation yet.

We in fact really shouldn't be emitting calls at all, since an imported
explicit instantiation always exists in the TU we imported it from.  So
this patch adjusts DECL_NOT_REALLY_EXTERN handling to account for this.

PR c++/120125

gcc/cp/ChangeLog:

* module.cc (trees_out::write_function_def): Only set
DECL_NOT_REALLY_EXTERN if the importer might need to emit it.
* optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph
node created.

gcc/testsuite/ChangeLog:

* g++.dg/modules/clone-4_a.C: New test.
* g++.dg/modules/clone-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/cp/optimize.cc
gcc/testsuite/g++.dg/modules/clone-4_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/clone-4_b.C [new file with mode: 0644]