From patchwork Mon Nov 6 14:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 162025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2680454vqu; Mon, 6 Nov 2023 06:07:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRiv1P/nwiAlNjVLzwZihQ6wb+wuhCoZzhjsyU685etf0T1O1JCk2ryXwXmc/g71NN1SaW X-Received: by 2002:a67:b802:0:b0:45f:9ee:d1c8 with SMTP id i2-20020a67b802000000b0045f09eed1c8mr3999525vsf.20.1699279655598; Mon, 06 Nov 2023 06:07:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699279655; cv=pass; d=google.com; s=arc-20160816; b=Uprzddr4pgy5nKsC226xXi6NvpZ2mYP3C2CkVPIHUeZBKh77HyiA0ZMR+2P8KRPogl 420hg7JCX+gAKqZThOlsclENtmhiP/QMF7J2gTW3lF1kMaMDb4DDXIaEhpszZvBaKTYZ 39Uh+8IEmj7MPnxE2OKhOgIbvOzJ/onYQgb0KuTsPaLl7V0+NWfKcN5ctKCf7ApHObeS GPvX8kX8BWPn+IpuBsT5ZIZrjr/MSquBN/ZS7bD8x/7vp1s3K0QLO3cVUP0SQLh21Lif OM3QGeW0mfVP6cbSt+fUKHwLuOX/r/cYqAQKBjNk0c8u6TxtxWYXAb7tCJ2dJn2Ek5C5 EvRQ== 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=8OxDk6KRDmKPewIC8yMx9fQ0y2+0rDMuqm2NLvAYPjA=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=ZU63nhrFn2pr6aMPU7NMnxGdW4zrXfcVC/0Es/S510rvKECQPddfG/iS93CM8ias6F xOS4GiMt7fioE7jamt/QPH7Rr68uEXDPHhCB27MDTKJNtpKivg7CMu7hlpMFDPhGavVZ xvChzHWNIH5rIlQS5cMDZRbRNAtmHTCcjAbY6SzGpQ5A+hr5MGMrBRWtcDEtQ8EwZzsU JN1gezgxWSTUirCtjIEHdFTVgfzN4PnSgyPO9Ny7V59aqlyKB2wMKvWJ/DjYAbc46l0x fMMAeOrruPvpoQca1IzaEn64L7vmLLkGVnR5HGpBws4kRTNP6wymnSVc9D/nV+pHr5wi InTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RxPFOnFW; 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 t25-20020a0561020a1900b00457b2ad8bc5si866462vsa.573.2023.11.06.06.07.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:07:35 -0800 (PST) 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=RxPFOnFW; 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 5245F3856DC6 for ; Mon, 6 Nov 2023 14:07:35 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1B6043858C20 for ; Mon, 6 Nov 2023 14:07:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B6043858C20 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 1B6043858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699279633; cv=none; b=aX/iE/+aLtmr2QBN+pcFUumSzIPrfOtxh0HkrA5vXtL5eHdO0WHQo+y29bEpblIkdEOGVm5wZu37OOttCdggjUgQMhy0+VjDkYoLY4Y8P+bLq8+RqqHxrYhf974SUnTNggpXtudExvKHmmNjgfD/EP/1wG6yogpDPEK9ljNVHm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699279633; c=relaxed/simple; bh=ktJ8mm7n3DhodQ0P8eeDdC7mXBhgoIKxV2i7KoMJZo8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qopw1nl9AciZ77c7wsVJL/thc+SPu4kTBZZj0NoA0hmnbC8NWMgZrVb2SNvcs67AAyvFkwKVo6za6Nv0OYCsBWX5rx+LytePMlUttRrMglCDYkERNFVr/FLWo9Q87br7ai7KhBUOZkwXXjXerB3N7S+Ek2dBE7z82Rh3K4upGRk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699279631; 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=8OxDk6KRDmKPewIC8yMx9fQ0y2+0rDMuqm2NLvAYPjA=; b=RxPFOnFWTtE/WGXpESy/zRmI78hn6vn+Iq0MmsrkdOxbQxaMknelwq1GLFUzJHWw4EMa19 7FvZQeMwBNTt0J0JRa1CfEH08yhbFBlj4XTia6scXRUMDKR9Krxup3GGyew5pl9aiSm3+Q pmJtB3poDG66gNjcQXkBxZ/f/n1YEoc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-Zrfkov_yOladT6v8oWQOfg-1; Mon, 06 Nov 2023 09:06:41 -0500 X-MC-Unique: Zrfkov_yOladT6v8oWQOfg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8183B28B72E6 for ; Mon, 6 Nov 2023 14:06:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0079F1121306 for ; Mon, 6 Nov 2023 14:06:40 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] c-family: Enable -fpermissive for C and ObjC Date: Mon, 06 Nov 2023 15:06:39 +0100 Message-ID: <874jhzgemo.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.3 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_H4, RCVD_IN_MSPIKE_WL, 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.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: 1781823864320222550 X-GMAIL-MSGID: 1781823864320222550 Future changes will treat some C front end warnings similar to -Wnarrowing. 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. --- v2: Rebased after David's m_* member changes. Still no test suite regressions. Actual tests will need some C permerrors, which we do not yet have. 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: 3cc9ad41db87fb85b13a56bff1f930c258542a70 diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index a980912f7e1..dbf92be9698 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->m_pedantic_errors) + { + flag_permissive = 1; + global_dc->m_permissive = 1; + } lang_hooks.name = "GNU C89"; } diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 29d3d789a49..cc3a6610148 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2112,7 +2112,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 6e776a0faa1..dfa01220b93 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6170,13 +6170,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