re PR lto/53808 (Undefined symbol when building a library with lto)
authorJason Merrill <jason@redhat.com>
Wed, 30 Jul 2014 21:29:25 +0000 (17:29 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 30 Jul 2014 21:29:25 +0000 (17:29 -0400)
PR lto/53808
PR c++/61659
* pt.c (push_template_decl_real): Don't set DECL_COMDAT on friends.

From-SVN: r213311

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

index f0102077620006156a4c11f5b983afe75caef956..3d85843584477781fe64b7382c7a02a1feaf1a89 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 33a8bf47151b37e06039edd139a5be7ac3003366..baabcb1aa5b93aa0e1599803e7075154fdadcb35 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() { }