From patchwork Wed Aug 7 15:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter0x44 X-Patchwork-Id: 1970142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=NMrbkpOo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WfGmr16djz1yfC for ; Thu, 8 Aug 2024 03:06:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BB6B3858429 for ; Wed, 7 Aug 2024 17:06:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 3C7EA3858C56 for ; Wed, 7 Aug 2024 17:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C7EA3858C56 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=disroot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3C7EA3858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723050392; cv=none; b=Ih9vWD8Pg3Pt9RWYvxGKun3Asej/eTB9IsI3aJrlI+1O0NwYMe5JJV5BUFC0T4npOSc5Vepj/IM3zyIODHVXAKh1x4o/zLzFm0dBApqQxAKiafL9kQr5+gVUnihOQawlDfiPRMIL0pN4ptlsuw4VdareKq5SJEwxm0kQwiWCwEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723050392; c=relaxed/simple; bh=+fUcu3op106BWNHDz46RqYZ753LCQJtuhtc/8wqTWMg=; h=From:DKIM-Signature:To:Subject:Date:Message-Id:MIME-Version; b=reAejzK7IKLgg2Kbcvs49j+3fngtyMf9Jj//KoIUfAc8AF4pKEn6T9/UG51aVei6H0lN5NtHpFpkzCXSPX+eEFkdGbLgFGA7cKPJxjP1xkutV8tT8BbexnYCUr/eXIZR7BiRgMf/d5ysi8kbRCDqPKL42PHpK4u57z3KAUp7COM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A42E641A74; Wed, 7 Aug 2024 19:06:27 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6UhmM807ZQOr; Wed, 7 Aug 2024 19:06:27 +0200 (CEST) From: Peter Damianov DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1723050386; bh=+fUcu3op106BWNHDz46RqYZ753LCQJtuhtc/8wqTWMg=; h=From:To:Cc:Subject:Date; b=NMrbkpOomxIMNMdSLSziO3a9mCCZHzvQAkNwE+wp0KGqf8Gq8CH+LqfMKcEPHt376 OuIqOhD0pS3myiPB/Cy9qJCibXIR/MNkPpyD9VeJLzWGpW4jKgG9PsKu5AR1euy9P0 tYynHbhr6FX+zaL1Dmatu5imQ35sTULu7F4eUBp1fuG9orN3xFPyrQ7YEtN/69WfBh ZVjeZlqMe2i0KpNaYYpVkkreccYWJhjortfBu6cDRgrtTjjbIPg0b1qNWrFdDDfD4B ZHhOf/YZq1PTUREuAw/ApTwyqRrXtUBBhWnd2fslNVaD8R+LN7lyr6OaXqNz855Swm xyxGKOg7FrRow== To: gcc-patches@gcc.gnu.org Cc: Peter Damianov Subject: [PATCH v2] diagnostics: Follow DECL_ORIGIN in lhd_print_error_function [PR102061] Date: Wed, 7 Aug 2024 16:40:28 +0100 Message-Id: <20240807154026.11510-1-peter0x44@disroot.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org Currently, if a warning references a cloned function, the name of the cloned function will be emitted in the "In function %qs" part of the diagnostic, which users aren't supposed to see. This patch follows the DECL_ORIGIN link to get the name of the original function. gcc/ChangeLog: PR diagnostics/102061 * langhooks.cc (lhd_print_error_function): Follow DECL_ORIGIN link Signed-off-by: Peter Damianov --- I struggled to write a testcase for this, as none of the real world cases I tried reduced to anything nice. Hopefully it's okay to skip it at this time. gcc/langhooks.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index 61f2b676256..ab5f0932310 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -395,6 +395,8 @@ lhd_print_error_function (diagnostic_context *context, const char *file, else fndecl = current_function_decl; + fndecl = DECL_ORIGIN(fndecl); + if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) pp_printf (context->printer, _("In member function %qs"),