public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for implicit abi_tag on template member function
@ 2016-04-06 16:22 Jason Merrill
  2016-04-11 13:37 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2016-04-06 16:22 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 228 bytes --]

We were incorrectly omitting the ABI tag on the instantiation of this 
member function because we were setting the tags on the instantiation 
and looking for them on the temploid.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: abi-tag-fntmp.patch --]
[-- Type: text/x-patch, Size: 1252 bytes --]

commit 32a5b18940f37dd97c2735f24a8353d1db457d86
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 6 07:45:02 2016 -0400

    	* class.c (check_abi_tags): Fix function template handling.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 937e41f..02a992f 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1604,6 +1604,15 @@ check_abi_tags (tree t, tree subob)
 void
 check_abi_tags (tree decl)
 {
+  tree t;
+  if (abi_version_at_least (10)
+      && DECL_LANG_SPECIFIC (decl)
+      && DECL_USE_TEMPLATE (decl)
+      && (t = DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (decl)),
+	  t != decl))
+    /* Make sure that our template has the appropriate tags, since
+       write_unqualified_name looks for them there.  */
+    check_abi_tags (t);
   if (VAR_P (decl))
     check_abi_tags (decl, TREE_TYPE (decl));
   else if (TREE_CODE (decl) == FUNCTION_DECL
diff --git a/gcc/testsuite/g++.dg/abi/abi-tag19.C b/gcc/testsuite/g++.dg/abi/abi-tag19.C
new file mode 100644
index 0000000..e21d7b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/abi-tag19.C
@@ -0,0 +1,4 @@
+struct __attribute__((abi_tag("a"))) X { };
+template<typename T> struct Y { X f() { return X(); } };
+template struct Y<int>;
+// { dg-final { scan-assembler "_ZN1YIiE1fB1aEv" } }

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

* Re: C++ PATCH for implicit abi_tag on template member function
  2016-04-06 16:22 C++ PATCH for implicit abi_tag on template member function Jason Merrill
@ 2016-04-11 13:37 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2016-04-11 13:37 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

On 04/06/2016 12:22 PM, Jason Merrill wrote:
> We were incorrectly omitting the ABI tag on the instantiation of this
> member function because we were setting the tags on the instantiation
> and looking for them on the temploid.

Still not quite right...

Tested x86_64-pc-linux-gnu, applying to trunk.



[-- Attachment #2: abi-tag-mtmp2.patch --]
[-- Type: text/x-patch, Size: 1858 bytes --]

commit 6e6a82cf6bad124a9d97622a6f42968baf72ba2b
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Apr 9 12:07:26 2016 -0400

    	* mangle.c (decl_is_template_id): The template itself counts as a
    	template-id.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 5d38373..0e44409 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -264,9 +264,9 @@ static void write_java_integer_type_codes (const tree);
 #define write_unsigned_number(NUMBER)					\
   write_number ((NUMBER), /*unsigned_p=*/1, 10)
 
-/* If DECL is a template instance, return nonzero and, if
-   TEMPLATE_INFO is non-NULL, set *TEMPLATE_INFO to its template info.
-   Otherwise return zero.  */
+/* If DECL is a template instance (including the uninstantiated template
+   itself), return nonzero and, if TEMPLATE_INFO is non-NULL, set
+   *TEMPLATE_INFO to its template info.  Otherwise return zero.  */
 
 static int
 decl_is_template_id (const tree decl, tree* const template_info)
@@ -290,7 +290,8 @@ decl_is_template_id (const tree decl, tree* const template_info)
     {
       /* Check if this is a primary template.  */
       if (DECL_LANG_SPECIFIC (decl) != NULL
-	  && DECL_USE_TEMPLATE (decl)
+	  && VAR_OR_FUNCTION_DECL_P (decl)
+	  && DECL_TEMPLATE_INFO (decl)
 	  && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (decl))
 	  && TREE_CODE (decl) != TEMPLATE_DECL)
 	{
diff --git a/gcc/testsuite/g++.dg/abi/abi-tag20.C b/gcc/testsuite/g++.dg/abi/abi-tag20.C
new file mode 100644
index 0000000..229c170
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/abi-tag20.C
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+// { dg-final { scan-assembler "_ZN1B1gIcEEN7__cxx111XEv" } }
+
+inline namespace __cxx11 __attribute__((__abi_tag__ ("ABI_TAG"))) {
+  class X {};
+}
+struct B {
+  X f();
+  template <class U> X g();
+};
+int main() {
+  B b;
+  b.g<char>();
+  return 0;
+}

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

end of thread, other threads:[~2016-04-11 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 16:22 C++ PATCH for implicit abi_tag on template member function Jason Merrill
2016-04-11 13:37 ` Jason Merrill

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