From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 3B75A3857736 for ; Mon, 15 May 2023 13:56:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B75A3857736 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684158977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FHsTW+Q9q5ElfiARcyOGdJi+SDszliERpE0hnXikByk=; b=YyabELvBt4RRG8XHmyGTMo5JIB2IufxYYQ9JTyIcYBLi2umOoOibiLXYK8Erqq+DAfZ/GI aZommWt4ZvzCD0d/OlY9KQjEXHES9NjshTbfI7zygYDkFJYN/H3aA8YqQXz5rIIoEYZDVI qES+BdJIJp2AOsayhWdI4gae91xsipU= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-3thZAatDPPe8zKERYhETig-1; Mon, 15 May 2023 09:56:17 -0400 X-MC-Unique: 3thZAatDPPe8zKERYhETig-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-621323de4b4so112930016d6.3 for ; Mon, 15 May 2023 06:56:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684158976; x=1686750976; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FHsTW+Q9q5ElfiARcyOGdJi+SDszliERpE0hnXikByk=; b=PhtkXDmTneezazIRvBlc37+l/lG6bOPMKNYE3ryzL7e9Cw+Ft2AF/yZbiTX8oKQnic JBVlIce5A7MExN4mT7SUm51Pka8LeU8k+X4k8Cs4cAfPZq1ue5GPyhaXee+Y+p2BRo8/ CjL98CLKWcQrw8vxwAIFk7SimvaLFmW6xLiXGLOjxBKxJzyU3WH4MdMlGoFvsoPPpqgN fkmpCzjU4SwPqDxOPjiUdln0XThBNXDHHKrsSNgh2GwMjI4TJaAdt4hahMplMCTtUIRa pmYRwmkyrHKOo6ZQO2Tb75AG1aty7w8iS+9ZEq1/JTo5wO+Nt+28dTiHDDX+kQItZu7C HnVw== X-Gm-Message-State: AC+VfDy6dM0ErzL7xHPV0d2zRQlFT/LmcufVL2AFJw515bJaZh8jws3N EHbkoika0IS+6Qu4dUtYiUur73n6+RbM+3v0vsm4vqQxGSbVvGBgV1ALlwuc8H66dxk4tc99Bf9 l2b7SYe4lib0hMLFk9nhEv7BfzA== X-Received: by 2002:a05:6214:490:b0:5f4:5af6:1304 with SMTP id pt16-20020a056214049000b005f45af61304mr63036129qvb.16.1684158976044; Mon, 15 May 2023 06:56:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pn9XP7hlvgwVkgEOfWkkZa8MFWwvgWLdFyfj7HvhpjEZXQMaKZVubtlGK1WexXywPnCi3Aw== X-Received: by 2002:a05:6214:490:b0:5f4:5af6:1304 with SMTP id pt16-20020a056214049000b005f45af61304mr63036073qvb.16.1684158975598; Mon, 15 May 2023 06:56:15 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id t11-20020a0cf98b000000b005ea9156e72bsm4973381qvn.33.2023.05.15.06.56.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 06:56:15 -0700 (PDT) Message-ID: <8b265822-6a58-975d-4257-f7649a8d8a66@redhat.com> Date: Mon, 15 May 2023 09:56:13 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns To: Richard Biener Cc: gcc-patches@gcc.gnu.org References: <20230512205332.1781029-1-jason@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 5/15/23 03:32, Richard Biener wrote: > On Fri, May 12, 2023 at 10:54 PM Jason Merrill via Gcc-patches > 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 >> >