c++: cross-module __cxa_atexit use [PR 98531]
authorNathan Sidwell <nathan@acm.org>
Fri, 22 Jan 2021 16:48:27 +0000 (08:48 -0800)
committerNathan Sidwell <nathan@acm.org>
Mon, 8 Feb 2021 17:24:39 +0000 (09:24 -0800)
commit57b17858a1b3719507ccad926fb57b05f26935f8
tree96f2880edc112c71b8d86723b5e9adae1621d2ec
parent432b9f610dfb8a1c995c4752fe7b452cb1cd793b
c++: cross-module __cxa_atexit use [PR 98531]

The compiler's use of lazily-declared library functions must insert
said functions into a symbol table, so that they can be correctly
merged across TUs at the module-level.  We have too many different
ways of declaring such library functions.  This fixes __cxa_atexit (or
its system-specific variations), pushing (or merging) the decl into
the appropriate namespace.  Because we're pushing a lazy builtin,
check_redeclaration_exception_specification needed a tweak to allow a
such a builtin's eh spec to differ from what the user may have already
declared. (I suspect no all headers declare atexit as noexcept.)

We can't test the -fno-use-cxa-atexit path with modules, as that
requires a followup patch to a closely related piece (which also
affects cxa_atexit targets in other circumstances).

PR c++/98531
gcc/cp/
* cp-tree.h (push_abi_namespace, pop_abi_namespace): Declare.
* decl.c (push_abi_namespace, pop_abi_namespace): Moved
from rtti.c, add default namespace arg.
(check_redeclaration_exception_specification): Allow a lazy
builtin's eh spec to differ from an lready-declared user
declaration.
(declare_global_var): Use push/pop_abi_namespace.
(get_atexit_node): Push the fndecl into a namespace.
* rtti.c (push_abi_namespace, pop_abi_namespace): Moved to
decl.c.
gcc/testsuite/
* g++.dg/modules/pr98531-1.h: New.
* g++.dg/modules/pr98531-1_a.H: New.
* g++.dg/modules/pr98531-1_b.C: New.
* g++.dg/abi/pr98531-1.C: New.
* g++.dg/abi/pr98531-2.C: New.
* g++.dg/abi/pr98531-3.C: New.
* g++.dg/abi/pr98531-4.C: New.
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/rtti.c
gcc/testsuite/g++.dg/abi/pr98531-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr98531-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr98531-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr98531-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr98531-1.h [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr98531-1_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr98531-1_b.C [new file with mode: 0644]