From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id C17E23858D1E for ; Wed, 17 May 2023 06:39:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C17E23858D1E 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-x131.google.com with SMTP id 2adb3069b0e04-4f13c577e36so554925e87.1 for ; Tue, 16 May 2023 23:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684305581; x=1686897581; 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=hbJ/tEuDo+Ypexda/XJQ+ZF9iJ+/OXp7kyu9sWBy01Q=; b=BQW6hOVB6u0zGFG/KdlKOkiuhZQbucE7OSaNdfjZZfZkoKONNyN+TM0wUWrRR8rmI1 npQeVOexqLN2V8j5Q5AcVKWCDZBtqYWNGKWEWvrvN126mU4K3oenFMK/zJpH2CFCBSm6 55OVDif8/cKBhaOaEMJwtEylxWOnoxrZytLxri7vZaaUvdC0l78udvPLN6FXCWxr0ylk eQKwzhcTKqdpPs9Kim2A4PETPCQV1FfsZYfvHTYpdl53qpooVVJ2D6WeVIbOIFF9zi4t j9JPBnfeJ8FRA1dbXMDP2+AK+JkeoUnuTRpTcGrproAQ+3Bef2VGu9Jsi3njZFnOzx98 LNKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684305581; x=1686897581; 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=hbJ/tEuDo+Ypexda/XJQ+ZF9iJ+/OXp7kyu9sWBy01Q=; b=GJHM9BngxvSM8e/29uA6WjPVBxkOaf7DQ8uEb/cxJUn/p4GKZE6zFbh9c322M7rYO/ 34UxRmhJXGX4K9xmQrierlQgOcBncGWGh/fCZX8yxJEQEqkqBPYqUIcXs8w7udOdIoJN ccpVs3kvlrLkGz0RR6lNOKmg8HXgvD+oWj4yK8rm8Bb3Ro34i0c3xS2DvDLVnnUSQbME kvp16a31D1kxjtGHkbHlNOr7nMQhCJvutXZzOKMd4iWQd0+vQbEOj01Pmr5FQ0Cu4Q8q EZnecPuYr1b/6n19VHZr7kM2D35N4x5D/OgMHITNVAz8q+lT88ysYhIo05+UHne7tbRS ANbg== X-Gm-Message-State: AC+VfDyOslV2bf9rCrARYpsfQsTAYSVYB+wnVwZ91hPgNvDJBgmeRdcG r8auj1JXk7UeHbiL45JWkemT0IgY5W68Ux5RCO/Mk59A8E8= X-Google-Smtp-Source: ACHHUZ6M0sj2CJT4ljBedCbGvTiDf7cVMbzcbYy+YmzF3t1vy6maL0kkvTw22b25s1lK+3CaaHd5fdkhhgJbAqhkvWY= X-Received: by 2002:ac2:430f:0:b0:4e6:9b01:b92b with SMTP id l15-20020ac2430f000000b004e69b01b92bmr7584061lfh.67.1684305580784; Tue, 16 May 2023 23:39:40 -0700 (PDT) MIME-Version: 1.0 References: <20230512205332.1781029-1-jason@redhat.com> <8b265822-6a58-975d-4257-f7649a8d8a66@redhat.com> In-Reply-To: <8b265822-6a58-975d-4257-f7649a8d8a66@redhat.com> From: Richard Biener Date: Wed, 17 May 2023 08:39:27 +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=-6.9 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 Mon, May 15, 2023 at 3:56=E2=80=AFPM Jason Merrill wr= ote: > > On 5/15/23 03:32, Richard Biener wrote: > > 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 s= emantic > >> would be useful, but currently there is no easy way to access it. Bik= eshedding > >> welcome; the use of this flag is a bit odd, but it has the advantage o= f being > >> accepted without error going back at least to 4.3. > >> > >> -- 8< -- > >> > >> Currently there is no flag to use to upgrade all currently-enabled ped= warns > >> 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 t= o > >> 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 ne= gating > > 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 is= sued 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 implie= s > >> +@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 > >> > > >