From patchwork Thu Oct 19 08:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 155395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp241974vqb; Thu, 19 Oct 2023 01:44:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM2SQdrK7hr5eOY/LBgWI+q6A69kr1sHNu3XIvu4JxeNWCjFCSIUT5ym3uaJL7uPbSTrjr X-Received: by 2002:a67:c21e:0:b0:457:dcf3:50ba with SMTP id i30-20020a67c21e000000b00457dcf350bamr1501738vsj.26.1697705073817; Thu, 19 Oct 2023 01:44:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697705073; cv=pass; d=google.com; s=arc-20160816; b=VZ8BSmXog4YtpimCcz71nnPzsnzeOUcthIo3nOAIYU6yWyW38il43FPWQqekgskWmq IVPEZSD+D2xE9MBVEWfV9VGHPVuZCVBZH23qrsVjqgGDTMGtQ8AiaEY+ltT0vfvQwAML HfYIaqjwRQeMypje2aLPLetUuXo3PoEuph3QRL5E5ak4B7dGSwjpAo/0jy11wzY6x2tC 5nPYuhRiu6GmS/Z4rksvBaJQWXITh9RXSzNi7Jgm7P3/CZOsHw/1KNJWVKU3Zy9eJJjr CpL9L0S0k1WQrPC0ses+34RetZWwekO7cg6mqT9NyluKGI9sWFMxfgd68Z8HamJGmg+4 OVmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:to:from:dkim-signature:arc-filter :dmarc-filter:delivered-to; bh=NNisXr6h03+sRORW+Ja8RkdS4CnJ03QHCINUmZhTrk4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=SGJNAvYEHuKN49IKJ0m/1PUREAzcV/zBdZZuLv8ckXzHRX6QDdC/J9xKljuIYYAGoj dVyW2irBV9anBj4WaMkRAyyPksdiAW9AjqPC3TFHb6Zkl5s2oPPTpGGbPble2m0yBjgF BXaZiH/o2Y3vUFOZa+auaap3lhtwKImOzCoOpIlDS5af1Ju+hdO5KQ2WMZfGkF3vGp3L 7B0eqZCdFHTcQDhsS8v602i/ULGdlXpXlnSxoMe5wRhD73fn48XaVFG3+yMwerkoLbLJ iYpGtlcjayoPBFw81tau9OLOEaNhdLS4pQVOqLrECBVMIQYqN/OVcNVfLqCdhr2yXTWN d9qg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O49+qfXU; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h4-20020a05620a284400b00773b7d9a01esi1232546qkp.72.2023.10.19.01.44.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:44:33 -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=@redhat.com header.s=mimecast20190719 header.b=O49+qfXU; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC31D3861871 for ; Thu, 19 Oct 2023 08:44:27 +0000 (GMT) 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 612B1385E021 for ; Thu, 19 Oct 2023 08:43:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 612B1385E021 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 612B1385E021 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697705041; cv=none; b=DoFk+PXH/1Hricy0mEdYTSMUFexzMqr5aayh+40MknmDZOASTNXoZpUPfto4XPj9UXz1Kf/ZP0I/nlc1zxj6vs9uBgMSwflwEyn5OadTn28ZMveo+6PNpmSaRm69f02YxsSc09KNilEPYsBMHrlvk52/YXNnMjHPow1G6FhO9u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697705041; c=relaxed/simple; bh=mjBDGkvM5gzxuzJSj0U7F7Ugxads1lq3xt0kVQSR6vM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NbTYUBKlCPeT9EMOihFEt6EZndvzYHdVwYR2VQOchvRp/bCabkcs2HYZfV2FEAozwc+xzUghjAQCQXLCym0p2DVhDlEaqa4ikhf5tBElcRVfUkP4aHV/1nJw8iFDynA5R3azFvnELERLdmdwvHrnsYrc2AGQ6dSOu1mK/ME0q7Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697705036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=NNisXr6h03+sRORW+Ja8RkdS4CnJ03QHCINUmZhTrk4=; b=O49+qfXU5Ce4g8ZnNvv9evYzek1g2lT63J5L6v1UIfARbP9TqYVTXot4Q6/XO0m7y+gPOp p8COr4wjqghnbMFOf6/5CpMg+co1xL7pEAwid+XcK+1awW1LIOGF/AjHJOhard0A0+jQ3s DDTSl/4wqakpcbRuNM7j+Dz/i+1+NhA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-4sT_N5ePPbC9ATTeEN2grQ-1; Thu, 19 Oct 2023 04:43:54 -0400 X-MC-Unique: 4sT_N5ePPbC9ATTeEN2grQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B8462815E24 for ; Thu, 19 Oct 2023 08:43:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9540492BFB for ; Thu, 19 Oct 2023 08:43:53 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH] c-family: Enable -fpermissive for C and ObjC Date: Thu, 19 Oct 2023 10:43:52 +0200 Message-ID: <87il73rohj.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780172795746216411 X-GMAIL-MSGID: 1780172795746216411 Future changes will treat some C front end warnings similar to -Wnarrowing. There are no new tests because there are no such C warnings yet. The existing test suite covers the -std=gnu89 -pedantic-errors corner cases (which should not turn on -fpermissive). gcc/ * doc/invoke.texi (Warning Options): Mention C diagnostics for -fpermissive. gcc/c-family/ * c.opt (fpermissive): Enable for C and ObjC. * c-opts.cc (set_std_c89): Enable -fpermissive. --- gcc/c-family/c-opts.cc | 6 ++++++ gcc/c-family/c.opt | 2 +- gcc/doc/invoke.texi | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) base-commit: 8f4bbdc28df6e87a7ad5ec5ca191a7a836a4f016 diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index ce2e021e69d..9a4beb4b024 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -1711,6 +1711,12 @@ set_std_c89 (int c94, int iso) flag_isoc99 = 0; flag_isoc11 = 0; flag_isoc2x = 0; + /* -std=gnu89 etc. should not override -pedantic-errors. */ + if (!global_dc->pedantic_errors) + { + flag_permissive = 1; + global_dc->permissive = 1; + } lang_hooks.name = "GNU C89"; } diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 44b9c862c14..e6ea5e52d24 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2108,7 +2108,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/doc/invoke.texi b/gcc/doc/invoke.texi index 9b5ff457027..cfebab78f83 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6166,13 +6166,17 @@ errors by @option{-pedantic-errors}. For instance: Downgrade some required diagnostics about nonconformant code from errors to warnings. Thus, using @option{-fpermissive} allows some nonconforming code to compile. Some C++ diagnostics are controlled -only by this flag, but it also downgrades some diagnostics that have -their own flag: +only by this flag, but it also downgrades some C and C++ diagnostics +that have their own flag: @gccoptlist{ -Wnarrowing @r{(C++)} } +The @option{-fpermissive} option is the default for historic C language +modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90}, +@option{-std=gnu90}). + @opindex Wall @opindex Wno-all @item -Wall