c++: Always use pushdecl for exception library helpers
authorNathan Sidwell <nathan@acm.org>
Mon, 6 Jul 2020 16:54:40 +0000 (09:54 -0700)
committerNathan Sidwell <nathan@acm.org>
Mon, 6 Jul 2020 17:02:46 +0000 (10:02 -0700)
commite88218fd5a21e44c77c10dec87af4b11c76f34a0
treeee1cbca72c47e5a0af0ae3e8193b043751aea610
parentf2151227dfe90a5fe73297c370786be98b0b090f
c++: Always use pushdecl for exception library helpers

The ABI exception helpers like __throw were being created by first
looking for them, and then adding if not found.  Primarily because
libitm wasn't declaring them with the correct exception specifiers.  I
fixed libitm a while back, so let's just use push_library_fn and let
the symbol table machinery deal with duplicates.  push_library_fn was
making the assumtion there wasn't already a decl available, by always
returning the new decl.  Bad things would happen if there was a
duplicate, because duplicate_decls explicitly gcc_frees the new decl.
Fixed by having it return whatever pushdecl returns.

gcc/cp/
* decl.c (push_library_fn): Return the decl pushdecl_toplevel returns.
* except.c (verify_library_fn): Replace with ...
(declare_library_fn_1): ... this fn.  Always push the fn.
(declare_library_fn): Call it.
(build_throw): Call declare_library_fn_1.
gcc/testsuite/
* g++.dg/eh/builtin10.C: Adjust expected errors.
* g++.dg/eh/builtin11.C: Likewise.
* g++.dg/eh/builtin5.C: Likewise.
* g++.dg/eh/builtin6.C: Likewise.
* g++.dg/eh/builtin7.C: Likewise.
* g++.dg/eh/builtin9.C: Likewise.
* g++.dg/parse/crash55.C: Likewise.
gcc/cp/decl.c
gcc/cp/except.c
gcc/testsuite/g++.dg/eh/builtin10.C
gcc/testsuite/g++.dg/eh/builtin11.C
gcc/testsuite/g++.dg/eh/builtin5.C
gcc/testsuite/g++.dg/eh/builtin6.C
gcc/testsuite/g++.dg/eh/builtin7.C
gcc/testsuite/g++.dg/eh/builtin9.C
gcc/testsuite/g++.dg/parse/crash55.C