c++: Fix -Wnoexcept handling of system headers (PR90992).
authorJason Merrill <jason@redhat.com>
Sun, 26 Jan 2020 05:37:24 +0000 (00:37 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 27 Jan 2020 02:26:17 +0000 (21:26 -0500)
commit5035cd662459b09605370f2ba41b2238119c69b1
tree92714a88784da28de205aa1159b73407cf1601cd
parentcf17dcc6fc1f9f69d592952c2dd5796a5665bd5a
c++: Fix -Wnoexcept handling of system headers (PR90992).

The immediate issue here was that the second warning didn't depend on the
first one, so if the first location was in a system header, we'd
mysteriously give the second by itself.

It's also the case that the thing we care about being in a system header is
the function that we want to suggest adding 'noexcept' to, not the
noexcept-expression; it's useful to suggest adding noexcept to a user
function to satisfy a noexcept-expression in a system header.

PR c++/90992
* except.c (maybe_noexcept_warning): Check DECL_IN_SYSTEM_HEADER and
temporarily enable -Wsystem-headers.  Change second warning to
conditional inform.
gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/g++.dg/warn/Wnoexcept1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wnoexcept1.h [new file with mode: 0644]