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 48D013858425 for ; Fri, 12 May 2023 20:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48D013858425 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=1683924817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X84S0qmtI/JzGFjBzIuzz/Dj7gv6QEnoqCP69UHT0VA=; b=H9HYBPiiZAKNOcnBA/FezxGmXWE6Kjdt4vhM4QFuRmv6bdLSJFhNNLL/TI1lThYIt0X1Nz 5xUlYeNKdEDnYr0QVSWO6LsMQT2gBrG6yZQZ52IVoct0BLKXnlMvP325EWCgI8kVZzKn/j qm3FQ2X3yyDJLf7ikqeVB9o38++tAbM= 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-Google-Smtp-Source: ACHHUZ66hlh2RPkC4SIdV3eMeMG74vACoZ+W1EZFgDhfCRvE1PepCS4XimPJZ2ZaXPAD/06NAaH7rQ== 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) From: Jason Merrill 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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(-) 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