* [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns
@ 2023-05-12 20:53 Jason Merrill
2023-05-15 7:32 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2023-05-12 20:53 UTC (permalink / raw)
To: gcc-patches
In the context of the recent discussion, it occurred to me that this semantic
would be useful, but currently there is no easy way to access it. Bikeshedding
welcome; the use of this flag is a bit odd, but it has the advantage of being
accepted without error going back at least to 4.3.
-- 8< --
Currently there is no flag to use to upgrade all currently-enabled pedwarns
from warning to error. -pedantic-errors also enables the -Wpedantic
pedwarns, while -Werror=pedantic uselessly makes only the -Wpedantic
pedwarns errors.
I suggest that since -fpermissive lowers some diagnostics from error to
warning, -fno-permissive could do the reverse.
gcc/ChangeLog:
* doc/invoke.texi: Document -fno-permissive.
gcc/c-family/ChangeLog:
* c.opt (fpermissive): Accept in C and ObjC as well.
* c-opts.cc (c_common_post_options): -fno-permissive sets
global_dc->pedantic_errors.
---
gcc/doc/invoke.texi | 7 +++++++
gcc/c-family/c.opt | 2 +-
gcc/c-family/c-opts.cc | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b92b8576027..6198df14382 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3438,11 +3438,18 @@ issue. Currently, the only such diagnostic issued by G++ is the one for
a name having multiple meanings within a class.
@opindex fpermissive
+@opindex fno-permissive
@item -fpermissive
Downgrade some diagnostics about nonconformant code from errors to
warnings. Thus, using @option{-fpermissive} allows some
nonconforming code to compile.
+Conversely, @option{-fno-permissive} can be used to upgrade some
+diagnostics about nonconformant code from warnings to errors. This
+differs from @option{-pedantic-errors} in that the latter also implies
+@option{-Wpedantic}; this option does not enable additional
+diagnostics, only upgrades the severity of those that are enabled.
+
@opindex fno-pretty-templates
@opindex fpretty-templates
@item -fno-pretty-templates
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 3333cddeece..07165d2bbe8 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -2075,7 +2075,7 @@ C ObjC C++ ObjC++
Look for and use PCH files even when preprocessing.
fpermissive
-C++ ObjC++ Var(flag_permissive)
+C ObjC C++ ObjC++ Var(flag_permissive)
Downgrade conformance errors to warnings.
fplan9-extensions
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index c68a2a27469..1973c068d59 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1021,6 +1021,10 @@ c_common_post_options (const char **pfilename)
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
flag_delete_dead_exceptions, true);
+ if (!global_options_set.x_flag_pedantic_errors
+ && global_options_set.x_flag_permissive)
+ global_dc->pedantic_errors = !flag_permissive;
+
if (cxx_dialect >= cxx11)
{
/* If we're allowing C++0x constructs, don't warn about C++98
base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns
2023-05-12 20:53 [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns Jason Merrill
@ 2023-05-15 7:32 ` Richard Biener
2023-05-15 13:56 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2023-05-15 7:32 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Fri, May 12, 2023 at 10:54 PM Jason Merrill via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> In the context of the recent discussion, it occurred to me that this semantic
> would be useful, but currently there is no easy way to access it. Bikeshedding
> welcome; the use of this flag is a bit odd, but it has the advantage of being
> accepted without error going back at least to 4.3.
>
> -- 8< --
>
> Currently there is no flag to use to upgrade all currently-enabled pedwarns
> from warning to error. -pedantic-errors also enables the -Wpedantic
> pedwarns, while -Werror=pedantic uselessly makes only the -Wpedantic
> pedwarns errors.
>
> I suggest that since -fpermissive lowers some diagnostics from error to
> warning, -fno-permissive could do the reverse.
Hmm, but that makes '-fno-permissive' different from '-fpermissive
-fno-permissive'?
What about '-fpermissive -fno-permissive -fno-permissive' then?
So I think over-loading -fno-permissive with differen semantics from negating
the option is bad.
Richard.
>
> gcc/ChangeLog:
>
> * doc/invoke.texi: Document -fno-permissive.
>
> gcc/c-family/ChangeLog:
>
> * c.opt (fpermissive): Accept in C and ObjC as well.
> * c-opts.cc (c_common_post_options): -fno-permissive sets
> global_dc->pedantic_errors.
> ---
> gcc/doc/invoke.texi | 7 +++++++
> gcc/c-family/c.opt | 2 +-
> gcc/c-family/c-opts.cc | 4 ++++
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index b92b8576027..6198df14382 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -3438,11 +3438,18 @@ issue. Currently, the only such diagnostic issued by G++ is the one for
> a name having multiple meanings within a class.
>
> @opindex fpermissive
> +@opindex fno-permissive
> @item -fpermissive
> Downgrade some diagnostics about nonconformant code from errors to
> warnings. Thus, using @option{-fpermissive} allows some
> nonconforming code to compile.
>
> +Conversely, @option{-fno-permissive} can be used to upgrade some
> +diagnostics about nonconformant code from warnings to errors. This
> +differs from @option{-pedantic-errors} in that the latter also implies
> +@option{-Wpedantic}; this option does not enable additional
> +diagnostics, only upgrades the severity of those that are enabled.
> +
> @opindex fno-pretty-templates
> @opindex fpretty-templates
> @item -fno-pretty-templates
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 3333cddeece..07165d2bbe8 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -2075,7 +2075,7 @@ C ObjC C++ ObjC++
> Look for and use PCH files even when preprocessing.
>
> fpermissive
> -C++ ObjC++ Var(flag_permissive)
> +C ObjC C++ ObjC++ Var(flag_permissive)
> Downgrade conformance errors to warnings.
>
> fplan9-extensions
> diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
> index c68a2a27469..1973c068d59 100644
> --- a/gcc/c-family/c-opts.cc
> +++ b/gcc/c-family/c-opts.cc
> @@ -1021,6 +1021,10 @@ c_common_post_options (const char **pfilename)
> SET_OPTION_IF_UNSET (&global_options, &global_options_set,
> flag_delete_dead_exceptions, true);
>
> + if (!global_options_set.x_flag_pedantic_errors
> + && global_options_set.x_flag_permissive)
> + global_dc->pedantic_errors = !flag_permissive;
> +
> if (cxx_dialect >= cxx11)
> {
> /* If we're allowing C++0x constructs, don't warn about C++98
>
> base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns
2023-05-15 7:32 ` Richard Biener
@ 2023-05-15 13:56 ` Jason Merrill
2023-05-17 6:39 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2023-05-15 13:56 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On 5/15/23 03:32, Richard Biener wrote:
> On Fri, May 12, 2023 at 10:54 PM Jason Merrill via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> In the context of the recent discussion, it occurred to me that this semantic
>> would be useful, but currently there is no easy way to access it. Bikeshedding
>> welcome; the use of this flag is a bit odd, but it has the advantage of being
>> accepted without error going back at least to 4.3.
>>
>> -- 8< --
>>
>> Currently there is no flag to use to upgrade all currently-enabled pedwarns
>> from warning to error. -pedantic-errors also enables the -Wpedantic
>> pedwarns, while -Werror=pedantic uselessly makes only the -Wpedantic
>> pedwarns errors.
>>
>> I suggest that since -fpermissive lowers some diagnostics from error to
>> warning, -fno-permissive could do the reverse.
>
> Hmm, but that makes '-fno-permissive' different from '-fpermissive
> -fno-permissive'?
> What about '-fpermissive -fno-permissive -fno-permissive' then?
>
> So I think over-loading -fno-permissive with differen semantics from negating
> the option is bad.
Fair enough. Any other thoughts? It occurs to me now that it is
already possible to specify this behavior with -pedantic-errors
-Wno-pedantic, maybe that's sufficient if a bit cumbersome.
>> gcc/ChangeLog:
>>
>> * doc/invoke.texi: Document -fno-permissive.
>>
>> gcc/c-family/ChangeLog:
>>
>> * c.opt (fpermissive): Accept in C and ObjC as well.
>> * c-opts.cc (c_common_post_options): -fno-permissive sets
>> global_dc->pedantic_errors.
>> ---
>> gcc/doc/invoke.texi | 7 +++++++
>> gcc/c-family/c.opt | 2 +-
>> gcc/c-family/c-opts.cc | 4 ++++
>> 3 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index b92b8576027..6198df14382 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -3438,11 +3438,18 @@ issue. Currently, the only such diagnostic issued by G++ is the one for
>> a name having multiple meanings within a class.
>>
>> @opindex fpermissive
>> +@opindex fno-permissive
>> @item -fpermissive
>> Downgrade some diagnostics about nonconformant code from errors to
>> warnings. Thus, using @option{-fpermissive} allows some
>> nonconforming code to compile.
>>
>> +Conversely, @option{-fno-permissive} can be used to upgrade some
>> +diagnostics about nonconformant code from warnings to errors. This
>> +differs from @option{-pedantic-errors} in that the latter also implies
>> +@option{-Wpedantic}; this option does not enable additional
>> +diagnostics, only upgrades the severity of those that are enabled.
>> +
>> @opindex fno-pretty-templates
>> @opindex fpretty-templates
>> @item -fno-pretty-templates
>> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
>> index 3333cddeece..07165d2bbe8 100644
>> --- a/gcc/c-family/c.opt
>> +++ b/gcc/c-family/c.opt
>> @@ -2075,7 +2075,7 @@ C ObjC C++ ObjC++
>> Look for and use PCH files even when preprocessing.
>>
>> fpermissive
>> -C++ ObjC++ Var(flag_permissive)
>> +C ObjC C++ ObjC++ Var(flag_permissive)
>> Downgrade conformance errors to warnings.
>>
>> fplan9-extensions
>> diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
>> index c68a2a27469..1973c068d59 100644
>> --- a/gcc/c-family/c-opts.cc
>> +++ b/gcc/c-family/c-opts.cc
>> @@ -1021,6 +1021,10 @@ c_common_post_options (const char **pfilename)
>> SET_OPTION_IF_UNSET (&global_options, &global_options_set,
>> flag_delete_dead_exceptions, true);
>>
>> + if (!global_options_set.x_flag_pedantic_errors
>> + && global_options_set.x_flag_permissive)
>> + global_dc->pedantic_errors = !flag_permissive;
>> +
>> if (cxx_dialect >= cxx11)
>> {
>> /* If we're allowing C++0x constructs, don't warn about C++98
>>
>> base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346
>> --
>> 2.31.1
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns
2023-05-15 13:56 ` Jason Merrill
@ 2023-05-17 6:39 ` Richard Biener
0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2023-05-17 6:39 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Mon, May 15, 2023 at 3:56 PM Jason Merrill <jason@redhat.com> wrote:
>
> On 5/15/23 03:32, Richard Biener wrote:
> > On Fri, May 12, 2023 at 10:54 PM Jason Merrill via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> In the context of the recent discussion, it occurred to me that this semantic
> >> would be useful, but currently there is no easy way to access it. Bikeshedding
> >> welcome; the use of this flag is a bit odd, but it has the advantage of being
> >> accepted without error going back at least to 4.3.
> >>
> >> -- 8< --
> >>
> >> Currently there is no flag to use to upgrade all currently-enabled pedwarns
> >> from warning to error. -pedantic-errors also enables the -Wpedantic
> >> pedwarns, while -Werror=pedantic uselessly makes only the -Wpedantic
> >> pedwarns errors.
> >>
> >> I suggest that since -fpermissive lowers some diagnostics from error to
> >> warning, -fno-permissive could do the reverse.
> >
> > Hmm, but that makes '-fno-permissive' different from '-fpermissive
> > -fno-permissive'?
> > What about '-fpermissive -fno-permissive -fno-permissive' then?
> >
> > So I think over-loading -fno-permissive with differen semantics from negating
> > the option is bad.
>
> Fair enough. Any other thoughts? It occurs to me now that it is
> already possible to specify this behavior with -pedantic-errors
> -Wno-pedantic, maybe that's sufficient if a bit cumbersome.
I guess so. Maybe the -fpermissive documentation could hint at
that for this case?
Richard.
> >> gcc/ChangeLog:
> >>
> >> * doc/invoke.texi: Document -fno-permissive.
> >>
> >> gcc/c-family/ChangeLog:
> >>
> >> * c.opt (fpermissive): Accept in C and ObjC as well.
> >> * c-opts.cc (c_common_post_options): -fno-permissive sets
> >> global_dc->pedantic_errors.
> >> ---
> >> gcc/doc/invoke.texi | 7 +++++++
> >> gcc/c-family/c.opt | 2 +-
> >> gcc/c-family/c-opts.cc | 4 ++++
> >> 3 files changed, 12 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> >> index b92b8576027..6198df14382 100644
> >> --- a/gcc/doc/invoke.texi
> >> +++ b/gcc/doc/invoke.texi
> >> @@ -3438,11 +3438,18 @@ issue. Currently, the only such diagnostic issued by G++ is the one for
> >> a name having multiple meanings within a class.
> >>
> >> @opindex fpermissive
> >> +@opindex fno-permissive
> >> @item -fpermissive
> >> Downgrade some diagnostics about nonconformant code from errors to
> >> warnings. Thus, using @option{-fpermissive} allows some
> >> nonconforming code to compile.
> >>
> >> +Conversely, @option{-fno-permissive} can be used to upgrade some
> >> +diagnostics about nonconformant code from warnings to errors. This
> >> +differs from @option{-pedantic-errors} in that the latter also implies
> >> +@option{-Wpedantic}; this option does not enable additional
> >> +diagnostics, only upgrades the severity of those that are enabled.
> >> +
> >> @opindex fno-pretty-templates
> >> @opindex fpretty-templates
> >> @item -fno-pretty-templates
> >> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> >> index 3333cddeece..07165d2bbe8 100644
> >> --- a/gcc/c-family/c.opt
> >> +++ b/gcc/c-family/c.opt
> >> @@ -2075,7 +2075,7 @@ C ObjC C++ ObjC++
> >> Look for and use PCH files even when preprocessing.
> >>
> >> fpermissive
> >> -C++ ObjC++ Var(flag_permissive)
> >> +C ObjC C++ ObjC++ Var(flag_permissive)
> >> Downgrade conformance errors to warnings.
> >>
> >> fplan9-extensions
> >> diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
> >> index c68a2a27469..1973c068d59 100644
> >> --- a/gcc/c-family/c-opts.cc
> >> +++ b/gcc/c-family/c-opts.cc
> >> @@ -1021,6 +1021,10 @@ c_common_post_options (const char **pfilename)
> >> SET_OPTION_IF_UNSET (&global_options, &global_options_set,
> >> flag_delete_dead_exceptions, true);
> >>
> >> + if (!global_options_set.x_flag_pedantic_errors
> >> + && global_options_set.x_flag_permissive)
> >> + global_dc->pedantic_errors = !flag_permissive;
> >> +
> >> if (cxx_dialect >= cxx11)
> >> {
> >> /* If we're allowing C++0x constructs, don't warn about C++98
> >>
> >> base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346
> >> --
> >> 2.31.1
> >>
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-17 6:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 20:53 [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns Jason Merrill
2023-05-15 7:32 ` Richard Biener
2023-05-15 13:56 ` Jason Merrill
2023-05-17 6:39 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).