From patchwork Sat Oct 28 19:14:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 159284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1362761vqb; Sat, 28 Oct 2023 12:14:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRZqCSBpwha6jYJAQrj/9pR+HQMdhS2EXt3Btm344M3CaKO33cwQjy18uLKJ0pmyJBgLaD X-Received: by 2002:ac8:5785:0:b0:41e:279d:ddc0 with SMTP id v5-20020ac85785000000b0041e279dddc0mr7060057qta.40.1698520478111; Sat, 28 Oct 2023 12:14:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698520478; cv=pass; d=google.com; s=arc-20160816; b=RJCQBSkza35wlCWQ1JgyGF8O+5O5S+KiHtTMiPAfGcO0g/I3khKaupAJ8g12E5m2Hz eNiqoT+PXH6DAziEigGNFLxrj3x4aWzUlQakvcwrbP6ABRpw0/C1waavRIdB06w72evE 0X2asWXz7VUgfG5d48bHuVzoBFgIfbJi8NtNWC48RetBAi1MHrETA2OBWMRVU4XeScbA A4qO3JMWzvNBAMxl+l37vSVa4nQ79+aP1Tb/aBCkLoD1uA4SC4fFx+fkAMmT7HUVvdhe tRfJOpuVrudmAO6N9tyIDUny1QmgG2YsxJ/Rol5GPj8FhQ+KRz6yMw+dYiZOMJqyVJWk p64A== 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:content-transfer-encoding :mime-version:feedback-id:message-id:subject:from:to:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=N6XvgTLjrmWjdVahGoRLHTdUhh058C//BzwqvutkNKY=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=ZJZ0Cx1j+1yXDZR2bPhN1KkWjp5UTQZq3pEtd/D3ur4Ks0JT9fHHLf/rC0CdQkS8fg 8fuci5ZEqjWhngN1VWhkyhIkFOQyOwyz+PJD13BPDIW+ygat5jsT+GVJAgX89xvUH0lE Yp/QIicOJrGgIw+Fv7A6rnLmJDubOpREtWvGfC6oxTvaz2QYlqgm0Q44ITdvQlGTQv3y ffGwrpYNk6HuDmB7yNj14fUnkfmT+mxAMLgDqeyxh5GvFj7rM1YhmkkPGa7bL6HnEMk+ vhfHBNZqLdEVHv0lBFtvOTf8NAD+aHDi3E7bchacYEAiS/0K6hBS3f2VZ3o7zHlYdEJl YBWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=mCzX9eOk; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o8-20020a05622a008800b0041cc02700dbsi2822902qtw.257.2023.10.28.12.14.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:14:38 -0700 (PDT) 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=@protonmail.com header.s=protonmail3 header.b=mCzX9eOk; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D08D838618C1 for ; Sat, 28 Oct 2023 19:14:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by sourceware.org (Postfix) with ESMTPS id 94B70385C6FC for ; Sat, 28 Oct 2023 19:14:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94B70385C6FC Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=protonmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 94B70385C6FC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698520454; cv=none; b=QUUkYNXynSPOJx8jZh5kBP9YShfrLgnu7yxTStAs1WjjI6r015Xa8qu/QTyAPD5VkpSJ1Vbc+JL6kLy+7mWWwb5clN5VimyO3EtcvEMjhQk1T3c0yikAJviQepFlMKnD2cgxyMM5Lyt29gw0PEa7vNvMZh4dwbu0GnvEQEBGm70= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698520454; c=relaxed/simple; bh=Cv7VU2YXOi5A2oqAexiuwZw7oqWslnSoWdW1h4aVuqg=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=KzN17ESjUXnEXqiflT9QfxZK4/T1xJd2oDrXWHYNK3obX9iTQeR4iX46392Er4s29nW9vyWFkwnsQHkfRfmdn0F15GS136X60r6RCVrorqfqh2RrcmHWlllVh2aovFsGbx7DWzrYmGZJOyiUnxUarizjQT/9Z2mwncZN7LpBUVw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1698520451; x=1698779651; bh=N6XvgTLjrmWjdVahGoRLHTdUhh058C//BzwqvutkNKY=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=mCzX9eOk6iMOQWBVpoewOQG3CTObirHJusAAmzItlmg3ERSusrlSKTvfyCmsGrqeB xlE3RaVydG4TGgnjawnXpY7ncrwsLF6xRFzBdqiJJXuDXe7+IhmgevcUhjLBMq1Bg5 MtDTP1r2By0Fv2F3R1MHtlev5Rb/H/LpMbIPeV0g+YTSysHw13Lh+cN9Jt47Anx36y z67CWuxisyY/nS3c6Xjdaklr9b2uPbqI4SENyZCd7zZjMg8a/CZcmkqNRuIHanleXN j3FK1Zn7FxNzKi263NWpvz3b80I+lyy1qmDShNgfZ0a/itIGpASusV/F6gVO4lZdQY neDq5nj4wKzNw== Date: Sat, 28 Oct 2023 19:14:05 +0000 To: gcc-patches@gcc.gnu.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1] c: Do not warn about external declaration following inline definition Message-ID: <20231028191402.217288-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, 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: 1781027808517739712 X-GMAIL-MSGID: 1781027808517739712 An external declaration following an inline definition is not redundant because it forces the compiler to emit an external definition for the function. That is, inline void f(void) { } [extern] void f(void); should not trigger the redundant redeclaration of ... warning. gcc/c/ChangeLog: * c-decl.cc (diagnose_mismatched_decls): Add new case for Wredundant-decls suppression. --- gcc/c/c-decl.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 7a145bed281..e86f7950858 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -2592,7 +2592,12 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl)) /* Don't warn about a variable definition following a declaration. */ && !(VAR_P (newdecl) - && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))) + && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)) + /* Don't warn about external declaration following inline definition. */ + && !(TREE_CODE (newdecl) == FUNCTION_DECL + && !DECL_INITIAL (newdecl) && !DECL_DECLARED_INLINE_P (newdecl) + && DECL_EXTERNAL (newdecl) && DECL_INITIAL (olddecl) + && DECL_DECLARED_INLINE_P (olddecl) && DECL_EXTERNAL (olddecl))) { warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D", newdecl);