c++: Prevent overwriting arguments when merging duplicates [PR112588]
commit3471a61ed0ddef70de8f1bbba85cd1e945fc86fd
authorNathaniel Shead <nathanieloshead@gmail.com>
Sat, 16 Dec 2023 10:34:45 +0000 (16 21:34 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 17 Jan 2024 23:06:09 +0000 (18 10:06 +1100)
treed76234f7f12cc224ed29a2e311889e47d3dd0cbf
parenteb71695f76378151cb38372051bf50aed792f36d
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>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/merge-16.h [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/merge-16_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/merge-16_b.C [new file with mode: 0644]