aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-07-08 14:35:58 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-07-11 21:05:29 +1000
commitf04f9714fca40315360af109b9e5ca2305fd75db (patch)
tree2e53b4f202eff229e2455768f9b53fbcf1aa5371 /gcc/testsuite/g++.dg
parentb3c686416e88bf135def0e72d316713af01445a1 (diff)
downloadgcc-f04f9714fca40315360af109b9e5ca2305fd75db.zip
gcc-f04f9714fca40315360af109b9e5ca2305fd75db.tar.gz
gcc-f04f9714fca40315360af109b9e5ca2305fd75db.tar.bz2
c++/modules: Keep entity mapping info across duplicate_decls [PR99241]
When duplicate_decls finds a match with an existing imported declaration, it clears DECL_LANG_SPECIFIC of the olddecl and replaces it with the contents of newdecl; this clears DECL_MODULE_ENTITY_P causing an ICE if the same declaration is imported again later. This fixes the issue by ensuring that the flag is transferred to newdecl before clearing so that it ends up on olddecl again. For future-proofing we also do the same with DECL_MODULE_KEYED_DECLS_P, though because we don't yet support textual redefinition merging we can't yet test this works as intended. I don't expect it's possible for a new declaration already to have extra keyed decls mismatching that of the old declaration though, so I don't do anything with 'keyed_map' at this time. PR c++/99241 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Merge module entity information. gcc/testsuite/ChangeLog: * g++.dg/modules/pr99241_a.H: New test. * g++.dg/modules/pr99241_b.H: New test. * g++.dg/modules/pr99241_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99241_a.H3
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99241_b.H3
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99241_c.C5
3 files changed, 11 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/modules/pr99241_a.H b/gcc/testsuite/g++.dg/modules/pr99241_a.H
new file mode 100644
index 0000000..c7031f0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr99241_a.H
@@ -0,0 +1,3 @@
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+void terminate();
diff --git a/gcc/testsuite/g++.dg/modules/pr99241_b.H b/gcc/testsuite/g++.dg/modules/pr99241_b.H
new file mode 100644
index 0000000..c7031f0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr99241_b.H
@@ -0,0 +1,3 @@
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+void terminate();
diff --git a/gcc/testsuite/g++.dg/modules/pr99241_c.C b/gcc/testsuite/g++.dg/modules/pr99241_c.C
new file mode 100644
index 0000000..7f2b1bb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr99241_c.C
@@ -0,0 +1,5 @@
+// { dg-additional-options "-fmodules-ts -fno-module-lazy" }
+
+import "pr99241_a.H";
+void terminate();
+import "pr99241_b.H";