c++: duplicate block-scope extern [PR 97877]
authorNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 21:16:47 +0000 (13:16 -0800)
committerNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 21:28:08 +0000 (13:28 -0800)
commite0da4aed176a8de042a8482beb65499e29448556
treed98eed6396db0ba31b16418d0dedc9f884f1c2b6
parent066c89d1e1c509975a0e76be4279e2505084bd3b
c++: duplicate block-scope extern [PR 97877]

We ICED with a duplicated block-scope extern, as duplicate_decls was
dropping the decl_lang_specific of olddecl.  Simplys adding
appropriate retrofitting and copying turned out to be insufficient
because you can get a block-scope using decl also matching the extern.
The latter seems a little suspicious and I have asked CWG for advice.
While there robustified the assert about releasing olddecls'
lang-specific -- if it had one, the new decl better have one.

PR c++/97877
gcc/cp/
* decl.c (duplicate_decls): Deal with duplicated DECL_LOCAL_DECL_P
decls.  Extend decl_lang_specific checking assert.
gcc/testsuite/
* g++.dg/lookup/pr97877.C: New.
gcc/cp/decl.c
gcc/testsuite/g++.dg/lookup/pr97877.C [new file with mode: 0644]