re PR c++/51827 (Error: 'FOO' conflicts with a previous declaration, with PCH/LTO...
authorJason Merrill <jason@redhat.com>
Mon, 16 Jan 2012 21:32:05 +0000 (16:32 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 16 Jan 2012 21:32:05 +0000 (16:32 -0500)
PR c++/51827
* mangle.c (mangle_decl): Don't mangle uninstantiated templates.

From-SVN: r183221

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pch/mangle1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/mangle1.Hs [new file with mode: 0644]

index a5a07e47db8357f22166b7202c312706feb461c7..e3ef5f2e8132b1f1a5f498ba8b13d3a6c9d60a19 100644 (file)
@@ -1,5 +1,8 @@
 2012-01-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/51827
+       * mangle.c (mangle_decl): Don't mangle uninstantiated templates.
+
        PR c++/51868
        * typeck.c (build_static_cast_1): Handle bit-fields properly.
 
index 5f2fa157a9c5f6510db760c27dc2fb652cf0f7a2..15b1aca09f55cdca03d03dd2f666f3a5a05d22a7 100644 (file)
@@ -3330,7 +3330,21 @@ get_mangled_id (tree decl)
 void
 mangle_decl (const tree decl)
 {
-  tree id = get_mangled_id (decl);
+  tree id;
+  bool dep;
+
+  /* Don't bother mangling uninstantiated templates.  */
+  ++processing_template_decl;
+  if (TREE_CODE (decl) == TYPE_DECL)
+    dep = dependent_type_p (TREE_TYPE (decl));
+  else
+    dep = (DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)
+          && any_dependent_template_arguments_p (DECL_TI_ARGS (decl)));
+  --processing_template_decl;
+  if (dep)
+    return;
+
+  id = get_mangled_id (decl);
   SET_DECL_ASSEMBLER_NAME (decl, id);
 
   if (G.need_abi_warning
index 82f9dd35e1f16e82abf0a900e8c6154e89d587ce..9fa8e43365f242bf092f8b54f539fe4da0fff688 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-16  Jason Merrill  <jason@redhat.com>
+
+       PR c++/51827
+       * g++.dg/pch/mangle1.{C,Hs}: New.
+
 2012-01-16  Mikael Morin  <mikael@gcc.gnu.org>
            Tobias Burnus  <burnus@net-b.de>
 
diff --git a/gcc/testsuite/g++.dg/pch/mangle1.C b/gcc/testsuite/g++.dg/pch/mangle1.C
new file mode 100644 (file)
index 0000000..504fa2d
--- /dev/null
@@ -0,0 +1,3 @@
+// { dg-options -std=c++11 }
+
+#include "mangle1.Hs"
diff --git a/gcc/testsuite/g++.dg/pch/mangle1.Hs b/gcc/testsuite/g++.dg/pch/mangle1.Hs
new file mode 100644 (file)
index 0000000..4d48c2e
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/51827
+// { dg-options "-flto -std=c++0x" }
+
+template<typename X> struct S { };
+template<typename Y> struct T {
+  template <typename ... A> T(S <A ...>);
+};
+inline void f(T<int>) { }