aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-08-21 01:08:36 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-10-25 08:13:22 +1100
commit29efc621b7c66ec67d10fc87cddbb3f1ab709fb2 (patch)
treea637e77f530261778e7e7222dcc4bebbedb7c74c /gcc/cp
parent058ed8705a7b38bef2c107b6ff5de243aebd57b4 (diff)
downloadgcc-29efc621b7c66ec67d10fc87cddbb3f1ab709fb2.zip
gcc-29efc621b7c66ec67d10fc87cddbb3f1ab709fb2.tar.gz
gcc-29efc621b7c66ec67d10fc87cddbb3f1ab709fb2.tar.bz2
c++/modules: Support decloned cdtors
When compiling with '-fdeclone-ctor-dtor' (enabled by default with -Os), we run into issues where we don't correctly emit the underlying functions. We also need to ensure that COMDAT constructors are marked as such before 'maybe_clone_body' attempts to propagate COMDAT groups to the new thunks. gcc/cp/ChangeLog: * module.cc (post_load_processing): Mark COMDAT as needed, emit declarations if maybe_clone_body fails. gcc/testsuite/ChangeLog: * g++.dg/modules/clone-2_a.C: New test. * g++.dg/modules/clone-2_b.C: New test. * g++.dg/modules/clone-3_a.C: New test. * g++.dg/modules/clone-3_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/module.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index d7494cc..90ad67d 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -17959,10 +17959,22 @@ post_load_processing ()
dump () && dump ("Post-load processing of %N", decl);
gcc_checking_assert (DECL_MAYBE_IN_CHARGE_CDTOR_P (decl));
- /* Cloning can cause loading -- specifically operator delete for
- the deleting dtor. */
- if (!TREE_ASM_WRITTEN (decl) && maybe_clone_body (decl))
- TREE_ASM_WRITTEN (decl) = 1;
+
+ if (DECL_COMDAT (decl))
+ comdat_linkage (decl);
+ if (!TREE_ASM_WRITTEN (decl))
+ {
+ /* Cloning can cause loading -- specifically operator delete for
+ the deleting dtor. */
+ if (maybe_clone_body (decl))
+ TREE_ASM_WRITTEN (decl) = 1;
+ else
+ {
+ /* We didn't clone the cdtor, make sure we emit it. */
+ note_vague_linkage_fn (decl);
+ cgraph_node::finalize_function (decl, true);
+ }
+ }
}
cfun = old_cfun;