From: Patrick Palka <ppalka@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: abi_tag attribute on templates [PR109715]
Date: Thu, 14 Dec 2023 16:08:13 -0500 (EST) [thread overview]
Message-ID: <49477513-edfe-7ab6-95d6-7ea3496707ac@idea> (raw)
In-Reply-To: <7ded5b9e-4718-4a48-9d18-5a88321d2163@redhat.com>
On Thu, 14 Dec 2023, Jason Merrill wrote:
> On 12/14/23 14:17, Patrick Palka wrote:
> > 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)?
>
> I think we do, sadly.
Sounds good, like so? Bootstrap and regtest in progress.
-- >8 --
Subject: [PATCH] c++: abi_tag attribute on templates [PR109715]
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.
* g++.dg/abi/abi-tag25a.C: New test.
---
gcc/cp/mangle.cc | 6 ++++++
gcc/testsuite/g++.dg/abi/abi-tag25.C | 17 +++++++++++++++++
gcc/testsuite/g++.dg/abi/abi-tag25a.C | 11 +++++++++++
3 files changed, 34 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/abi/abi-tag25.C
create mode 100644 gcc/testsuite/g++.dg/abi/abi-tag25a.C
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 0684f0e6038..e3383df1836 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -530,6 +530,12 @@ get_abi_tags (tree t)
if (DECL_P (t) && DECL_DECLARES_TYPE_P (t))
t = TREE_TYPE (t);
+ if (TREE_CODE (t) == TEMPLATE_DECL
+ && DECL_TEMPLATE_RESULT (t)
+ /* We used to ignore abi_tag on function and variable templates. */
+ && abi_check (19))
+ t = DECL_TEMPLATE_RESULT (t);
+
tree attrs;
if (TYPE_P (t))
attrs = TYPE_ATTRIBUTES (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<class T>
+[[gnu::abi_tag("foo")]] void fun() { }
+
+template void fun<int>();
+
+#if __cpp_variable_templates
+template<class T>
+[[gnu::abi_tag("foo")]] int var = 0;
+
+template int var<int>;
+#endif
+
+// { dg-final { scan-assembler "_Z3funB3fooIiEvv" } }
+// { dg-final { scan-assembler "_Z3varB3fooIiE" { target c++14 } } }
diff --git a/gcc/testsuite/g++.dg/abi/abi-tag25a.C b/gcc/testsuite/g++.dg/abi/abi-tag25a.C
new file mode 100644
index 00000000000..9499b5614cd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/abi-tag25a.C
@@ -0,0 +1,11 @@
+// PR c++/109715
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fabi-version=18 -fabi-compat-version=18 -Wabi=0" }
+
+#include "abi-tag25.C"
+
+// { dg-warning "mangled name" "" { target *-*-* } 5 }
+// { dg-warning "mangled name" "" { target *-*-* } 11 }
+
+// { dg-final { scan-assembler "_Z3funIiEvv" } }
+// { dg-final { scan-assembler "_Z3varIiE" { target c++14 } } }
--
2.43.0.76.g1a87c842ec
next prev parent reply other threads:[~2023-12-14 21:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 19:17 Patrick Palka
2023-12-14 20:33 ` Jason Merrill
2023-12-14 21:08 ` Patrick Palka [this message]
2023-12-14 22:09 ` Jason Merrill
2023-12-15 0:59 ` Patrick Palka
2023-12-15 1:26 ` Jason Merrill
2023-12-18 8:54 ` [committed] testsuite: Fix up abi-tag25a.C test for C++11 Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49477513-edfe-7ab6-95d6-7ea3496707ac@idea \
--to=ppalka@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).