On 12/14/23 16:08, Patrick Palka wrote:
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);
Generally I try to call abi_check only when we know that there's
something that will change the mangling, so here only if the template
has ABI tags. I suppose the only downside is a second mangling that
produces the same name and gets ignored in mangle_decl so we don't need
to be too strict about it, but it shouldn't be too hard to do that here?
Jason