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: 1860300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DUvl/UY0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SPJT670XZz1yQK for ; Tue, 7 Nov 2023 04:37:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0060D3858434 for ; Mon, 6 Nov 2023 17:37: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 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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