From: Jason Merrill Date: Mon, 16 Jan 2012 21:32:05 +0000 (-0500) Subject: re PR c++/51827 (Error: 'FOO' conflicts with a previous declaration, with PCH/LTO... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7cd72be0248ce0b24f61c603a3fc68fcb78baf3;p=gcc.git re PR c++/51827 (Error: 'FOO' conflicts with a previous declaration, with PCH/LTO/C++11) PR c++/51827 * mangle.c (mangle_decl): Don't mangle uninstantiated templates. From-SVN: r183221 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5a07e47db8..e3ef5f2e813 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-01-16 Jason Merrill + 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. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5f2fa157a9c..15b1aca09f5 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 82f9dd35e1f..9fa8e43365f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-16 Jason Merrill + + PR c++/51827 + * g++.dg/pch/mangle1.{C,Hs}: New. + 2012-01-16 Mikael Morin Tobias Burnus diff --git a/gcc/testsuite/g++.dg/pch/mangle1.C b/gcc/testsuite/g++.dg/pch/mangle1.C new file mode 100644 index 00000000000..504fa2dcb77 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/mangle1.C @@ -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 index 00000000000..4d48c2e2fe7 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/mangle1.Hs @@ -0,0 +1,8 @@ +// PR c++/51827 +// { dg-options "-flto -std=c++0x" } + +template struct S { }; +template struct T { + template T(S ); +}; +inline void f(T) { }