aboutsummaryrefslogtreecommitdiff
path: root/gcc/cse.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-05-16 17:02:51 -0400
committerJason Merrill <jason@redhat.com>2023-10-18 10:00:25 -0400
commitef10cb8683ae60c161eb88df381e02f95f6e3e30 (patch)
treee9cdb75ddb8e2b4268a88b0ed492a95a3936c3c8 /gcc/cse.cc
parentaf4bb221153359f5948da917d5ef2df738bb1e61 (diff)
downloadgcc-ef10cb8683ae60c161eb88df381e02f95f6e3e30.zip
gcc-ef10cb8683ae60c161eb88df381e02f95f6e3e30.tar.gz
gcc-ef10cb8683ae60c161eb88df381e02f95f6e3e30.tar.bz2
diagnostic: add permerror variants with opt
In the discussion of promoting some pedwarns to be errors by default, rather than move them all into -fpermissive it seems to me to make sense to support DK_PERMERROR with an option flag. This way will also work with -fpermissive, but users can also still use -Wno-error=narrowing to downgrade that specific diagnostic rather than everything affected by -fpermissive. So, for diagnostics that we want to make errors by default we can just change the pedwarn call to permerror. The tests check desired behavior for such a permerror in a system header with various flags. The patch preserves the existing permerror behavior of ignoring -w and system headers by default, but respecting them when downgraded to a warning by -fpermissive. This seems similar to but a bit better than the approach of forcing -pedantic-errors that I previously used for -Wnarrowing: specifically, in that now -w by itself is not enough to silence the -Wnarrowing error (integer-pack2.C). gcc/ChangeLog: * doc/invoke.texi: Move -fpermissive to Warning Options. * diagnostic.cc (update_effective_level_from_pragmas): Remove redundant system header check. (diagnostic_report_diagnostic): Move down syshdr/-w check. (diagnostic_impl): Handle DK_PERMERROR with an option number. (permerror): Add new overloads. * diagnostic-core.h (permerror): Declare them. gcc/cp/ChangeLog: * typeck2.cc (check_narrowing): Use permerror. gcc/testsuite/ChangeLog: * g++.dg/ext/integer-pack2.C: Add -fpermissive. * g++.dg/diagnostic/sys-narrow.h: New test. * g++.dg/diagnostic/sys-narrow1.C: New test. * g++.dg/diagnostic/sys-narrow1a.C: New test. * g++.dg/diagnostic/sys-narrow1b.C: New test. * g++.dg/diagnostic/sys-narrow1c.C: New test. * g++.dg/diagnostic/sys-narrow1d.C: New test. * g++.dg/diagnostic/sys-narrow1e.C: New test. * g++.dg/diagnostic/sys-narrow1f.C: New test. * g++.dg/diagnostic/sys-narrow1g.C: New test. * g++.dg/diagnostic/sys-narrow1h.C: New test. * g++.dg/diagnostic/sys-narrow1i.C: New test.
Diffstat (limited to 'gcc/cse.cc')
0 files changed, 0 insertions, 0 deletions