We were silently accepting the pr65923.C specialization of std::swap with
the wrong exception specification; it should be declared noexcept. Let's
limit ignoring mismatch with system headers to extern "C" functions so we
get a diagnostic for the C++ library.
In the case of an omitted exception-specification, let's also lower the
error to a pedwarn, and copy the missing spec over, to avoid a hard break
for code that accidentally relied on the old behavior.
...except extern "C" functions keep the new spec, to avoid breaking dubious
code like noexcept-type19.C.
gcc/cp/ChangeLog:
* decl.cc (check_redeclaration_exception_specification): Remove
OPT_Wsystem_headers from pedwarn when the old declaration is
in a system header. Also check std namespace.