From patchwork Thu Dec 14 19:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1876363 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=S165FjFf; 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 4Srhv92Kg8z20H6 for ; Fri, 15 Dec 2023 06:17:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E3EC385842D for ; Thu, 14 Dec 2023 19:17:38 +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 19935385842D for ; Thu, 14 Dec 2023 19:17:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19935385842D 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 19935385842D 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=1702581447; cv=none; b=aPyChxcRET3eDxoh0OlYSvwv1+69uF+yyPyU5azl5fxbjkRaRZCN+GukS2H5OL4fMbiJ/udUNZ4wwCQTMimev942CwDMCVhmTS4TuNxC35YBtekXPLa3rw6grck3Lr3BjnHwNiIghFEFUEIMqX0cJulJbpufgEm3TLLEcNCxKTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702581447; c=relaxed/simple; bh=fwHeuKDW5sLf33hXC+lEGRnFeMSfjBbQ7+Woq6/9eis=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=g5hR9P7LA7UKud6zx79SUFgJ4E2z2y3deSQwlPA5vGnZn0XAOBDyUE1cZn5qsG/088vAlrz5LZAn4AoCsyYXGNFpZr4S6mIF9dxUKaKrDefYvUnh8l53u8LWq/7sU107FI05Zv169eSk30B2Ds1Hf/Js/AKChi/U/TgC8tpg2AM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702581445; 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: content-transfer-encoding:content-transfer-encoding; bh=j/PvOczgLnPE5ky7sXB4m7Nd+UWGhYNl6DkVjRaWrZU=; b=S165FjFffbiiJPJn2dtoLzQa4vHh6/gHHBmwm+WpYwEUxX9b3hjGwtpRdtFRD0Rh3dfVXY FXuVauFBA2THWIfNmVl22HLs70/+kZsPPWoH2SB33qRRWsicFEe9BPfIZJrMsIrawg9pzg QHxmUMOlBX5f/f2S+0QSNeG73C+b9hw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-y8uBlWn2N1OVK8qtD7LPGA-1; Thu, 14 Dec 2023 14:17:23 -0500 X-MC-Unique: y8uBlWn2N1OVK8qtD7LPGA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-425965b3da4so16239961cf.1 for ; Thu, 14 Dec 2023 11:17:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702581441; x=1703186241; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j/PvOczgLnPE5ky7sXB4m7Nd+UWGhYNl6DkVjRaWrZU=; b=G7FV2K4CyTzyILGifG4KO4QVZ4wdVEe9c3eWZxPKMhXi+587XuYuhy3Q9EfrTplfGB svzFs67cJ4yoWKU7q44GtHb4/niv+pBP7lS2YTwQqGlnQ5VmqTvMpWN7uPhYbc5kWim6 FEMzYfofb9VA9qzaGtXxK09tJwzzCtLoia7yidLn7TBGdEuiYe7r5zDZa5gemM9VQWeG SJbKbGmqB2m2u2odaY6S7Rlpxoji1EC09PRMt4U+Afnw6gfYiac6Vcd95fcznviHeG6P YT7hHjApmke89AxaMqtTHI4Q9l3wBg8Z35dTOwZAUCd21p6X7PNL+eNp2jKei4ZOkUMR MlYg== X-Gm-Message-State: AOJu0YyMN1/RSgjpMC6us+OBsOv0g7rXNN2bhjehz7R2q9zNgqHDIbrQ frxw7PWtNa1yXwHJOOcrYj5h+YMUvt36ESD8uVj3giEsmITT+KWICeJ1c7UtYTop2Bu+hDDWW+m 9CWhn/9uXxFWtk8buppO5t4cN+SPQLoVk436mbgoqXZqL9z7VmGna72NlkAccq9ij36vVDgVnax k= X-Received: by 2002:a05:622a:1207:b0:423:8345:369f with SMTP id y7-20020a05622a120700b004238345369fmr14045701qtx.7.1702581441759; Thu, 14 Dec 2023 11:17:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1x2F8nuWl9/jfFuYwdzB5fF5yPzORfBsWhUum0aOKTSx1iKjkxU92DXzzz2JLfPCjGDpzZg== X-Received: by 2002:a05:622a:1207:b0:423:8345:369f with SMTP id y7-20020a05622a120700b004238345369fmr14045686qtx.7.1702581441476; Thu, 14 Dec 2023 11:17:21 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id h20-20020ac846d4000000b00423a3f5ea75sm5982260qto.21.2023.12.14.11.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 11:17:20 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: abi_tag attribute on templates [PR109715] Date: Thu, 14 Dec 2023 14:17:19 -0500 Message-ID: <20231214191719.1941342-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.76.g1a87c842ec MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.6 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? Do we want to condition this on abi_check (19)? -- >8 -- As with other declaration attributes, we need to look through TEMPLATE_DECL when looking up the abi_tag attribute. PR c++/109715 gcc/cp/ChangeLog: * mangle.cc (get_abi_tags): Look through TEMPLATE_DECL. gcc/testsuite/ChangeLog: * g++.dg/abi/abi-tag25.C: New test. --- gcc/cp/mangle.cc | 3 +++ gcc/testsuite/g++.dg/abi/abi-tag25.C | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/abi/abi-tag25.C diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index 0684f0e6038..1fbd879c116 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -527,6 +527,9 @@ get_abi_tags (tree t) if (!t || TREE_CODE (t) == NAMESPACE_DECL) return NULL_TREE; + if (TREE_CODE (t) == TEMPLATE_DECL && DECL_TEMPLATE_RESULT (t)) + t = DECL_TEMPLATE_RESULT (t); + if (DECL_P (t) && DECL_DECLARES_TYPE_P (t)) t = TREE_TYPE (t); diff --git a/gcc/testsuite/g++.dg/abi/abi-tag25.C b/gcc/testsuite/g++.dg/abi/abi-tag25.C new file mode 100644 index 00000000000..9847f0dccc8 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/abi-tag25.C @@ -0,0 +1,17 @@ +// PR c++/109715 +// { dg-do compile { target c++11 } } + +template +[[gnu::abi_tag("foo")]] void fun() { } + +template void fun(); + +#if __cpp_variable_templates +template +[[gnu::abi_tag("foo")]] int var = 0; + +template int var; +#endif + +// { dg-final { scan-assembler "_Z3funB3fooIiEvv" } } +// { dg-final { scan-assembler "_Z3varB3fooIiE" { target c++14 } } }