From patchwork Mon Nov 6 17:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 162096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2818697vqu; Mon, 6 Nov 2023 09:37:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTBTVluJosn4Kk+L9paBc5PWf3BgEBwQ//fS4zjCGpJgqEf9dLEU4FtXwniCfn43826j/I X-Received: by 2002:a05:620a:4312:b0:77b:9360:8844 with SMTP id u18-20020a05620a431200b0077b93608844mr4293749qko.48.1699292259251; Mon, 06 Nov 2023 09:37:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699292259; cv=pass; d=google.com; s=arc-20160816; b=MMd2Ib6OJNmoW30CTfvszIL9Oa/fKhqpOm4YExZ3s3K2ZmTzLwrx7vbaIuRyO6JN3B WgwIPTGj7wDIFo/rl9S4bPK/AbuznMdevQ8FllMizkWQzWJ/grnyhweeTOduurmvmyGN Cfa915ZPIm+c1iGCYeKy5QJ8eHX9V9nrXQeE2gCAOITRhTIeYXuDXd8SpI6evWDSFUyz Gi7/muV39yb8Dq23UOD4Os0bvjgzQgdO18YE4MDaMUp17YSAp96Z+Ku1GORkMWQbjznH anVSbhr7M3sDJu2Nyi+/RMMaK1H2BBD4ZPwol7Nb1Ww+Tw5Npk2f9bQhugU1L5YxiWj4 xLQQ== 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:cc:to:from:dkim-signature:arc-filter :dmarc-filter:delivered-to; bh=d2ZbxCmAlVbMbmYsj838vkSjj0u4pKVj50tzicsVmQA=; fh=Hz/QWAL2vMAbrm3W16QrnQrLktFWGNewssxaKtdN1w4=; b=fKpoLBvDFIo5XXVLNBmxourzeOyEnqzpmrXlKIO0vmJ2G1CDWBSReRrmR5Y8uBnfQ9 Koj8pkKHi1vq/jqw9SxUO90U7ve8QMx0qvngl3uoaqmt/TvzhOgTjBLzfKmIKu0z+3da se02M1SAIBBayi61ayqCWOCJiypki2E0OjncLwlX5q8sNZ4k9XcXxndtUv5l1oFBlf1d wnR4qANwPG72g3tlDTtky8jDb89lbkQqne8dokt+q/FoipSy17ktAtOrPgfhpb3roTgh MlciXznzGkwHM1Hn4gSFmw2s2GBBapMPaeNxNQY1NfvxmCIXrfaL1xKsggqBepgr6ruA l/yw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="DUvl/UY0"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id d20-20020a05620a241400b007789724e9ecsi5967099qkn.597.2023.11.06.09.37.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 09:37:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="DUvl/UY0"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 08F0A3857BA4 for ; Mon, 6 Nov 2023 17:37:39 +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 6B89B3858D20 for ; Mon, 6 Nov 2023 17:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B89B3858D20 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 6B89B3858D20 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=1699292236; cv=none; b=xzTxi+7yQZjDntokHyiO4AaNV/0iN5Giw1MMWtsbeN6Ru6rvNu7/4irx3zT3hUuC4ezofxMFDq9CJwLuCNpI/4qVRz7BxaBgYn1QYIx9lr1idTJN5A/6En/B5QqGgevxLVNrdf/9F0WpUm5CkdCe2jWoUjfP74UOTEasf5Umh0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699292236; c=relaxed/simple; bh=NM1bY0HdUMnSmhQ+kRUaaNyes1sA9Tjf9uEEznH1ILw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sXz0mv+hIGX8OxwesFaLtSOjOAXl75lJdkRdhH5xUqupei3q2p2ZCC140NvEvNsmHjjv1F6iRVpCFJ+/LVUmMnQPJe6hWPPfBfdQTStJg+GQqja5rSP8gwFNdl0mkllHeuvMli1MdDkuPn1HWLaqIGHhpW+xDToKD3ZcfnHCvdQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699292235; 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; bh=d2ZbxCmAlVbMbmYsj838vkSjj0u4pKVj50tzicsVmQA=; b=DUvl/UY01+JZWHAMkUxJW0T30Fo8QtD1LiBJUwKhghkdXbuuFILDNXjTc95KCEN+tOWNP4 NZwa1sod5zMJBvVGg4t6fpqvMrDh0OUkpzL+RjE30xxIcIpXfrSUUB2Ed9BzXxwsC3GaBp M7/P+4DC/yIwnbkA6lb/KHjun8bqghs= 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-230-scCAPYXtMNWLWX0NdCcb3g-1; Mon, 06 Nov 2023 12:37:13 -0500 X-MC-Unique: scCAPYXtMNWLWX0NdCcb3g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 78D9D3C2364A for ; Mon, 6 Nov 2023 17:37:13 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D048640C6EB9; Mon, 6 Nov 2023 17:37:12 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Subject: [PATCH] c-family: Enable -fpermissive for C and ObjC Date: Mon, 06 Nov 2023 18:37:11 +0100 Message-ID: <87msvqeqbc.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.2 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, 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: 1781837079705548579 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 (c_common_post_options): Enable -fpermissive. --- v3: Handle -fpermissive in c_common_post_options, to get useful behavior for various -std=gnu99 -fpermissive -std=gnu89 permutations. gcc/c-family/c-opts.cc | 12 ++++++++++++ gcc/c-family/c.opt | 2 +- gcc/doc/invoke.texi | 8 ++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) base-commit: 3cc9ad41db87fb85b13a56bff1f930c258542a70 diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index a980912f7e1..23ea79ec802 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -854,6 +854,18 @@ c_common_post_options (const char **pfilename) && flag_unsafe_math_optimizations == 0) flag_fp_contract_mode = FP_CONTRACT_OFF; + /* C language modes before C99 enable -fpermissive by default, but + only if -pedantic-errors is not specified. Also treat + -fno-permissive as a subset of -pedantic-errors that does not + reject certain GNU extensions also present the defaults for later + language modes. */ + if (!c_dialect_cxx () && !flag_isoc99 && !global_dc->m_pedantic_errors + && !global_options_set.x_flag_permissive) + { + flag_permissive = 1; + global_dc->m_permissive = 1; + } + /* If we are compiling C, and we are outside of a standards mode, we can permit the new values from ISO/IEC TS 18661-3 for FLT_EVAL_METHOD. Otherwise, we must restrict the possible values to 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