public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: abi_tag attribute on templates [PR109715]
@ 2023-12-14 19:17 Patrick Palka
  2023-12-14 20:33 ` Jason Merrill
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Palka @ 2023-12-14 19:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, Patrick Palka

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<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 } } }
-- 
2.43.0.76.g1a87c842ec


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-18  8:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-14 19:17 [PATCH] c++: abi_tag attribute on templates [PR109715] Patrick Palka
2023-12-14 20:33 ` Jason Merrill
2023-12-14 21:08   ` Patrick Palka
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

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).