aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2023-12-16 21:34:45 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-01-18 10:06:09 +1100
commit3471a61ed0ddef70de8f1bbba85cd1e945fc86fd (patch)
treed76234f7f12cc224ed29a2e311889e47d3dd0cbf /gcc/cp
parenteb71695f76378151cb38372051bf50aed792f36d (diff)
downloadgcc-3471a61ed0ddef70de8f1bbba85cd1e945fc86fd.zip
gcc-3471a61ed0ddef70de8f1bbba85cd1e945fc86fd.tar.gz
gcc-3471a61ed0ddef70de8f1bbba85cd1e945fc86fd.tar.bz2
c++: Prevent overwriting arguments when merging duplicates [PR112588]
When merging duplicate instantiations of function templates, currently read_function_def overwrites the arguments with that of the existing duplicate. This is problematic, however, since this means that the PARM_DECLs in the body of the function definition no longer match with the PARM_DECLs in the argument list, which causes issues when it comes to generating RTL. There doesn't seem to be any reason to do this replacement, so this patch removes that logic. PR c++/112588 gcc/cp/ChangeLog: * module.cc (trees_in::read_function_def): Don't overwrite arguments. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-16.h: New test. * g++.dg/modules/merge-16_a.C: New test. * g++.dg/modules/merge-16_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/module.cc2
1 files changed, 0 insertions, 2 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 350ad15..8db662c 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -11703,8 +11703,6 @@ trees_in::read_function_def (tree decl, tree maybe_template)
DECL_RESULT (decl) = result;
DECL_INITIAL (decl) = initial;
DECL_SAVED_TREE (decl) = saved;
- if (maybe_dup)
- DECL_ARGUMENTS (decl) = DECL_ARGUMENTS (maybe_dup);
if (context)
SET_DECL_FRIEND_CONTEXT (decl, context);