From patchwork Tue Nov 7 19:10:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 162695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp451145vqo; Tue, 7 Nov 2023 11:10:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9ZfnI1eHXcEAhG9ut3hPkwf+uiA/o6wFbEwZ3kAMho5L1EbcoA7bhmcwFEtNH+eu8y5wv X-Received: by 2002:a05:6871:af8c:b0:1e9:b9e6:98e1 with SMTP id zx12-20020a056871af8c00b001e9b9e698e1mr3008169oab.1.1699384239965; Tue, 07 Nov 2023 11:10:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699384239; cv=pass; d=google.com; s=arc-20160816; b=cFA4f7hQ691DhvZzIHb0+gezUP8x4wkGgh5jnjA3IXP3FNflk1w5s1lUitSoYGNWsy cU6C4bUBDqx0GUa2jomZOS1WjjPerGKxzy8O0tVwSY99FhHOSvKYfmO2JnDWnAUArpTr xR4EP5WnDRzq9dnj+wVjIvROMNbayz044n919/gengqe912Ke4rTJtqLIm/8sJCJme1/ tff6VPcQ4lOvRZSGxs5wCaqu9ezu3O/9+mwxibjiqg76pg84vuF3ds7H+yhIiuhhbDg2 B83xXPlhJApfiHOmI1o/wGv3u8IYc0HK1OAgPFWWZxxD7Lg1kuyD6Z7aJV9RqsxlBZGB OnOA== 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=fzkKexDunW6G2oS6VqA7h/ML1aU4hf4+5xaG0PUcq50=; fh=k5BQ3iYuwFTza1Z/H+kMrb8l2Z70j0hdnX84UNatFtM=; b=rM3jMYo04zijdwZ4Klo+lmjYcdb+5g8EUFuzoOVi1r+0aYwfnHHPzcgatWUxADgwug ZJTCIScSdsjIMUqxTKebiQDSc0ymwxUxG8NcGWzsPVxE4y1qeUyzowik7m/QMyl8OdiY Y4FGo79I4fBGvJbwvV5x6RwOcDYiuibnDGLOlZvJXjosSpuo6KLeftZ8i+qN3WHBdtMr AhfcIvl71vWrkbG2Cbymk+JgFu1HQR8Zk1RKgwLZXz6ZyTdztTQ4qC5sC5O0+0wId/3g BAX9ZMV9xU4oT32g65ExCYJ7NceOVuTaerFMow9TzeQkXVXMuyogX06CWquKjInmiPL3 FpJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bZatj3r6; 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 a15-20020a05622a02cf00b0041e5d30e0casi257377qtx.283.2023.11.07.11.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 11:10:39 -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=bZatj3r6; 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 AB8DA3858410 for ; Tue, 7 Nov 2023 19:10: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.129.124]) by sourceware.org (Postfix) with ESMTPS id 2320A3858D1E for ; Tue, 7 Nov 2023 19:10:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2320A3858D1E 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 2320A3858D1E 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=1699384216; cv=none; b=f6ObSLzv49Mj+hLy/YBWnQzgbxoiHGVLiBjrbt5iNAG0kirTCpEM8CEkW+hNJszqnXBkv7QmxIw3asHqa1IVoI6lgYwqQ/70qWyphFYN9EgxfeRuIUzYvCPgKr+QzLwnEY+mOKMUsubqkA6Ap7KdKJKl7vIhVlMu4vKLkHPGTQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699384216; c=relaxed/simple; bh=s0Pjh/v5l6fFr6mUP42ODoz07ZtDaBVL9KumS+7/PLo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=M71jUhWPMtRqy6NBibI2ZPP0giyLauRcHLcV1GUDjLZKb0VwrPq2HmYSw3Kph9wUO3mnwZtkLY8l6o2pwud5oC/3gt/m72EgUDFd0Kpcws9Z6HzPj7BQHTrxusEi0uTmkf/pxUw4P2V8gtw5a2OpvSgZSqTagUkyVqgzQQeBK6o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699384214; 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=fzkKexDunW6G2oS6VqA7h/ML1aU4hf4+5xaG0PUcq50=; b=bZatj3r6TIXvaI9ZtwfiY9ECye0p9Cr4cr+XVtEAIG9klhYKsX2QI64Md7DzMBDmd6Isjz vNtKM4kXf2chmOKAmwGxyqT9OJvqv20e77JE6F2sFhjphD0j9RaSarS6PBBbvlYWkmOStc G97t9PMN0G0tt6MILM72udLssAwaczA= 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-665-uwX6vAnCO2yGjU-aWnKD8g-1; Tue, 07 Nov 2023 14:10:13 -0500 X-MC-Unique: uwX6vAnCO2yGjU-aWnKD8g-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 C7161383DC6B; Tue, 7 Nov 2023 19:10:12 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 163961121306; Tue, 7 Nov 2023 19:10:11 +0000 (UTC) From: Florian Weimer To: gcc-patches@gcc.gnu.org Cc: Joseph Myers Subject: [PATCH v3] c-family: Enable -fpermissive for C and ObjC Date: Tue, 07 Nov 2023 20:10:10 +0100 Message-ID: <87sf5h9y7h.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: 1781933528738597199 X-GMAIL-MSGID: 1781933528738597199 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. (snip) Joseph, would you be able to review this? There are no new tests because there are no permerrors yet. Thanks, Florian --- v3: One operator per line, and use OPTION_SET_P. gcc/c-family/c-opts.cc | 14 ++++++++++++++ gcc/c-family/c.opt | 2 +- gcc/doc/invoke.texi | 8 ++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) base-commit: 7e3c58bfc1d957e48faf0752758da0fed811ed58 diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 87da6c180cd..a7963646fbc 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -854,6 +854,20 @@ 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 + && !OPTION_SET_P (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 359f071e632..4984cd796f4 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2116,7 +2116,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 80bb1efac40..8527dbd1823 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6174,13 +6174,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