]> 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:29:51 +0000 (19:29 +1000)
commit6dfc5d1fc86fe6aaed6e7c476286f7a5f0ffc867
tree5eddab2f36c32da0ca835d5f454145f1adb177ba
parent53690a84a35b905403126be66210d21e89f53ac6
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>
(cherry picked from commit d787bc4fd372298e9ed5b11cb3050fd3707070f6)
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]