From patchwork Fri May 12 20:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 93369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5384432vqo; Fri, 12 May 2023 13:54:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5No2jng2l1SPONXPov4G1nYWu4eIMxcvU53a8Yvuo39HXuhzNC5LZLN02fpx9en1tQRhwY X-Received: by 2002:a05:6402:202a:b0:504:8c1a:70db with SMTP id ay10-20020a056402202a00b005048c1a70dbmr23076955edb.32.1683924863603; Fri, 12 May 2023 13:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683924863; cv=none; d=google.com; s=arc-20160816; b=aYgOSLWMqUlZCNnf/Bytd1ORARjofw1OlxPPsYgz4KuYIp97b+Y5vef/SwAySNhucC Emc7iYo3UA2KA5V+U263pNGL9qJf/dVlliBwp9CXCBw6NQqjB5I0dr0WUx8qqdYRRbPi Z+oJNK9A95WroiZcEEzSQUsji49EjfD96PcTvX2KyazLw4ZLUjrc7elyFQpPLG8PS75Q MkXlneMmSaS0TKw4gT56yg0uGg4AOxAOaxl1TtP6MwoJ8epMXtnowajOqYRbr0NGSneB ZV4EzOpBN9AGRbpG1YIZiWFMKtXubQgxJSH/qu7nyJbCIYVTuh3Ma09GKgtbxAljxdEd rcgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=X84S0qmtI/JzGFjBzIuzz/Dj7gv6QEnoqCP69UHT0VA=; b=hP6brp3o2auVs0NGvkm5PUTlQ0cpWJAHV//ucST+pKJQrLBRqFKlUskOZrGNaRDL0f BFXNL6/giDv/G3q40Is40aHboVnARUOjUAHz+PmB4OXCBub7Zc3AHpb6IQMAvRJAIjTz eXvixxJYP9EWHdBLyisUlw37IHkEbcKtDQrAEy2bqi9+dC9qlR/OxRDC01ICenurFiGg 4Wx5hsohmIOw3laicaGiBeQuD2NZd9XtBtBoIeJVCiXu1ClLpB3pCGZCVgZBJfpApmDq 2m5rbXkrrGmGZYZMuH0HXKoCnvUpJ40E1conLsEv/wZjVkgae+R2Uw7qoyvWwYACz4I4 PBmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hAF1VxX2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g16-20020a056402181000b0050bc5673cecsi7691546edy.407.2023.05.12.13.54.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 13:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hAF1VxX2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4619C385701E for ; Fri, 12 May 2023 20:54:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4619C385701E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683924862; bh=X84S0qmtI/JzGFjBzIuzz/Dj7gv6QEnoqCP69UHT0VA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hAF1VxX2K/3xXPh7mGVZbdbCsk8ZufPaG8jODGbCVc0w7A3Jjme+bq5LGmMbWl5X2 RK/gSBnXHTTkeUN1/6hVUzczQxkIswsmFgFA24yHe/Wyg0X2FZy90OF1q4iMcQrRJI GUpth4y2IPgxH3a3PtovI8JILBTAo870QBO8p7/4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 48D013858425 for ; Fri, 12 May 2023 20:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48D013858425 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-W3F7PQ6CNnamg4zjBKvL_Q-1; Fri, 12 May 2023 16:53:36 -0400 X-MC-Unique: W3F7PQ6CNnamg4zjBKvL_Q-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-61b7ab3a89cso115033836d6.1 for ; Fri, 12 May 2023 13:53:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683924816; x=1686516816; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X84S0qmtI/JzGFjBzIuzz/Dj7gv6QEnoqCP69UHT0VA=; b=eMIfPi1muYfrkTVjCGqVhTeXPQ/wI4jWFmuYORsuigbsEzsLHvBPQ4HMY16w6RQn50 nEJQC1en8EtGGEXM6W7CpoRd+6c/WYKNc0vylsQL8KBUh3vmVsLhrTUKv5hRTCdBwcNl lKjXBanapRaRFZIZ4Ui1KFH2yGP7qd/pU1W0To81je2R+9Hwb3YW/43PKaXclv5Nkw8b YOxJExNMP0nNxT3XYG0fVvs/RPbPE/kSNclnMIi3XVM71VSQ2wlsh7pXBi6ZOVRb2cjM r26+TpHIfU0Od+dJr62fW3p8mQLSVDnTIsG9oU1MZZUaBfcK+C34AW04VmMHwVe4TnHK +fhg== X-Gm-Message-State: AC+VfDzrlh7P15Hjnk1Fsnd7RTTA55gTKTrgba/ve182gCGrWHAhvhot LyB6/NkohQyl1NMyL3/FWVrEdyeeZqCZ3DIing2Axgjcj+DJGHbLNWhKSgk3drsfs1zeRnDS8Xf opsf1sJA10RJfurRVUK2+lXpNxrwo10lg1FfT4f0FrdyQi8WggaItZnXZAGNCxEoJpA1OFBpSVw == X-Received: by 2002:a05:6214:509c:b0:621:363c:ea94 with SMTP id kk28-20020a056214509c00b00621363cea94mr23269480qvb.31.1683924815739; Fri, 12 May 2023 13:53:35 -0700 (PDT) X-Received: by 2002:a05:6214:509c:b0:621:363c:ea94 with SMTP id kk28-20020a056214509c00b00621363cea94mr23269448qvb.31.1683924815196; Fri, 12 May 2023 13:53:35 -0700 (PDT) Received: from jason.com (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 c3-20020a0cf2c3000000b0061c7431810esm2399764qvm.141.2023.05.12.13.53.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 13:53:34 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH RFC] c-family: make -fno-permissive upgrade pedwarns Date: Fri, 12 May 2023 16:53:32 -0400 Message-Id: <20230512205332.1781029-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765723197910952301?= X-GMAIL-MSGID: =?utf-8?q?1765723197910952301?= 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(-) base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346 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