From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id ED4E13858D32 for ; Mon, 15 May 2023 07:32:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED4E13858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f24ceae142so10742306e87.3 for ; Mon, 15 May 2023 00:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684135943; x=1686727943; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=P51cF0INc0Lz8roz83Q9GgASoTmitGsAqdzwrCBtr7M=; b=RGrO40OdeOsFRC980wCfRJfmt6HvROlURL2tmFwRmKIxPT68/BULNj6VU8WOYu3c1y haI32w7sAGsIGjrfIsAeLLbbM3lW43Co9O4OFwNtiwwXvtcV1v2pkhKVUeGHbe5A+Mol okivsFi74q4H0+bbpb2wbEDPhgP9kn2nxzAIFSCLMUiCsK9SiOWhddudFMEUq2VUjre6 3MY4mlqIVREQWCFh7CTQej7EkYHfJKfz9FZjGoLMWGWaoPUVR+f10FTdlkA2XIMvlF65 slw63pay/jWBzskz3OvlZ7bObRqpMlS0st/T96yGR1XWQ0LcXXSZ0ovaYPLk2TngOs95 TlWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684135943; x=1686727943; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P51cF0INc0Lz8roz83Q9GgASoTmitGsAqdzwrCBtr7M=; b=IPYp9LLI4UR6XRGF8oncg1hiqezgsuqzFxOc6g6+gT3ZEFgQBqREMZmjHPRDHzrjPI fSttTT43HYyRuz4CvrV8+fiFm8D12Pg+aEGoTeckX8zbl5OisyPkS2L6syKOmDQwFFUZ YB6IG0MSWAoEcX51I7AkL07OjxI3ANxnFwgyxrqlX0ExiNAE4FmXMsZonkU7GhzRxIgv SBruB96zoPNWaSlQxJTPP5E5fiNwkEZK719s2hLoLzoF7lcGfREMnHuCk1ClC2C2mxuO JsYir3iYw8afhe9ZxzU6vmeECTr3U0fLR44RMK72E3zNUPFatHS0vSGK9MEgo5+Iklh8 zfGg== X-Gm-Message-State: AC+VfDy58G+Ju7VSoeDiGomTGgXJfEqBRPWd+4uL7W6dbMr1gCxntBD4 UP4WfxTNczRnZO1CSNjrxJ9zLrvmlVpKZPEaUP8= X-Google-Smtp-Source: ACHHUZ79ZVzfFXPd3ISLu+C9vYPUcRF5WVPvLFSNXR0pQMydfEAf1JQZce+i4OWwo41+sC/Ystnc4ICKD92V3efiWy0= X-Received: by 2002:ac2:547c:0:b0:4f2:5aae:937 with SMTP id e28-20020ac2547c000000b004f25aae0937mr6036749lfn.64.1684135943191; Mon, 15 May 2023 00:32:23 -0700 (PDT) MIME-Version: 1.0 References: <20230512205332.1781029-1-jason@redhat.com> In-Reply-To: <20230512205332.1781029-1-jason@redhat.com> From: Richard Biener Date: Mon, 15 May 2023 09:32:11 +0200 Message-ID: Subject: Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, May 12, 2023 at 10:54=E2=80=AFPM Jason Merrill via Gcc-patches wrote: > > In the context of the recent discussion, it occurred to me that this sema= ntic > would be useful, but currently there is no easy way to access it. Bikesh= edding > welcome; the use of this flag is a bit odd, but it has the advantage of b= eing > accepted without error going back at least to 4.3. > > -- 8< -- > > Currently there is no flag to use to upgrade all currently-enabled pedwar= ns > from warning to error. -pedantic-errors also enables the -Wpedantic > pedwarns, while -Werror=3Dpedantic 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 negati= ng 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 issue= d 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 =3D !flag_permissive; > + > if (cxx_dialect >=3D cxx11) > { > /* If we're allowing C++0x constructs, don't warn about C++98 > > base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346 > -- > 2.31.1 >