From: Jason Merrill <jason@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns
Date: Mon, 15 May 2023 09:56:13 -0400 [thread overview]
Message-ID: <8b265822-6a58-975d-4257-f7649a8d8a66@redhat.com> (raw)
In-Reply-To: <CAFiYyc2zZntFAKpuQo3n5BJOctg41OwvzxarA7UBdmTKKYET2w@mail.gmail.com>
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
>>
>
next prev parent reply other threads:[~2023-05-15 13:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 20:53 Jason Merrill
2023-05-15 7:32 ` Richard Biener
2023-05-15 13:56 ` Jason Merrill [this message]
2023-05-17 6:39 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8b265822-6a58-975d-4257-f7649a8d8a66@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).