I think this should fix it.

Applying to trunk.

commit 939c2c7101765c2ac83c85871fa38cc2278a2e18
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Jul 30 17:19:23 2014 -0400

    	PR lto/53808
    	PR c++/61659
    	* pt.c (push_template_decl_real): Don't set DECL_COMDAT on friends.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 33a8bf4..baabcb1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..7dd5d48
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend56.C
@@ -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() { }

Reply via email to