PR lto/53808
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jul 2014 21:29:25 +0000 (21:29 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jul 2014 21:29:25 +0000 (21:29 +0000)
PR c++/61659
* pt.c (push_template_decl_real): Don't set DECL_COMDAT on friends.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213311 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/friend56.C [new file with mode: 0644]

index f010207..3d85843 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-30  Jason Merrill  <jason@redhat.com>
+
+       PR lto/53808
+       PR c++/61659
+       * pt.c (push_template_decl_real): Don't set DECL_COMDAT on friends.
+
 2014-07-30  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/57397
index 33a8bf4..baabcb1 100644 (file)
@@ -5021,6 +5021,7 @@ template arguments to %qD do not match original template %qD",
     }
 
   if (flag_implicit_templates
+      && !is_friend
       && VAR_OR_FUNCTION_DECL_P (decl))
     /* Set DECL_COMDAT on template instantiations; if we force
        them to be emitted by explicit instantiation or -frepo,
diff --git a/gcc/testsuite/g++.dg/template/friend56.C b/gcc/testsuite/g++.dg/template/friend56.C
new file mode 100644 (file)
index 0000000..7dd5d48
--- /dev/null
@@ -0,0 +1,13 @@
+// Make sure we don't mistakenly mark f as DECL_COMDAT.
+// { dg-final { scan-assembler "_Z1fv" } }
+
+void f();
+
+template <class T> struct A
+{
+  friend void f();
+};
+
+A<int> a;
+
+void f() { }