Re: PING Re: [PATCH v2 RFA] diagnostic: add permerror variants with opt
On Tue, Oct 17, 2023 at 9:51 PM Jason Merrill wrote: > > Ping? OK. Thanks, Richard. > On 10/3/23 17:09, Jason Merrill wrote: > > This revision changes from using DK_PEDWARN for permerror-with-option to > > using > > DK_PERMERROR. > > > > Tested x86_64-pc-linux-gnu. OK for trunk? > > > > -- 8< -- > > > > 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. > > --- > > gcc/doc/invoke.texi | 22 +++--- > > gcc/diagnostic-core.h | 3 + > > gcc/testsuite/g++.dg/diagnostic/sys-narrow.h | 2 + > > gcc/cp/typeck2.cc | 10 +-- > > gcc/diagnostic.cc | 67 --- > > gcc/testsuite/g++.dg/diagnostic/sys-narrow1.C | 4 ++ > > .../g++.dg/diagnostic/sys-narrow1a.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1b.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1c.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1d.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1e.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1f.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1g.C | 5 ++ > > .../g++.dg/diagnostic/sys-narrow1h.C | 6 ++ > > .../g++.dg/diagnostic/sys-narrow1i.C | 6 ++ > > gcc/testsuite/g++.dg/ext/integer-pack2.C | 2 +- > > 16 files changed, 117 insertions(+), 40 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow.h > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1a.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1b.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1c.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1d.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1e.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1f.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1g.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1h.C > > create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1i.C > > > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > > index 4085fc90907..6b6506a75b2 100644 > > --- a/gcc/doc/invoke.texi > > +++ b/gcc/doc/invoke.texi > > @@ -231,7 +231,7 @@ in the following sections. > > -fnew-inheriting-ctors > > -fnew-ttp-matching > > -fno-nonansi-builtins -fnothrow-opt -fno-operator-names > > --fno-optional-diags -fpermissive > > +-fno-optional-diags > > -fno-pretty-templates > > -fno-rtti -fsized-deallocation > > -ftemplate-backtrace-limit=@var{n} > > @@ -323,7 +323,7 @@ Objective-C and Objective-C++ Dialects}. > >
PING Re: [PATCH v2 RFA] diagnostic: add permerror variants with opt
Ping? On 10/3/23 17:09, Jason Merrill wrote: This revision changes from using DK_PEDWARN for permerror-with-option to using DK_PERMERROR. Tested x86_64-pc-linux-gnu. OK for trunk? -- 8< -- 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. --- gcc/doc/invoke.texi | 22 +++--- gcc/diagnostic-core.h | 3 + gcc/testsuite/g++.dg/diagnostic/sys-narrow.h | 2 + gcc/cp/typeck2.cc | 10 +-- gcc/diagnostic.cc | 67 --- gcc/testsuite/g++.dg/diagnostic/sys-narrow1.C | 4 ++ .../g++.dg/diagnostic/sys-narrow1a.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1b.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1c.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1d.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1e.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1f.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1g.C | 5 ++ .../g++.dg/diagnostic/sys-narrow1h.C | 6 ++ .../g++.dg/diagnostic/sys-narrow1i.C | 6 ++ gcc/testsuite/g++.dg/ext/integer-pack2.C | 2 +- 16 files changed, 117 insertions(+), 40 deletions(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow.h create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1a.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1b.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1c.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1d.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1e.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1f.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1g.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1h.C create mode 100644 gcc/testsuite/g++.dg/diagnostic/sys-narrow1i.C diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 4085fc90907..6b6506a75b2 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -231,7 +231,7 @@ in the following sections. -fnew-inheriting-ctors -fnew-ttp-matching -fno-nonansi-builtins -fnothrow-opt -fno-operator-names --fno-optional-diags -fpermissive +-fno-optional-diags -fno-pretty-templates -fno-rtti -fsized-deallocation -ftemplate-backtrace-limit=@var{n} @@ -323,7 +323,7 @@ Objective-C and Objective-C++ Dialects}. @item Warning Options @xref{Warning Options,,Options to Request or Suppress Warnings}. @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic --pedantic-errors +-pedantic-errors -fpermissive -w -Wextra -Wall -Wabi=@var{n} -Waddress -Wno-address-of-packed-member -Waggregate-return -Walloc-size-larger-than=@var{byte-size} -Walloc-zero @@ -3494,12 +3494,6 @@ Disable diagnostics that the standard says a