From bbe04f213da2a9ec4bbbaa4b50bed4c8b53a3e98 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 22 Jan 2012 15:56:34 -0500 Subject: [PATCH] re PR c++/51832 (Rev.182970 causes LTO link errors (multiple definitions of allocator_traits)) PR c++/51832 * varpool.c (varpool_analyze_pending_decls): Copy DECL_EXTERNAL for extra name aliases. From-SVN: r183396 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/lto/pr51832.h | 6 ++++++ gcc/testsuite/g++.dg/lto/pr51832_0.C | 7 +++++++ gcc/testsuite/g++.dg/lto/pr51832_1.C | 1 + gcc/varpool.c | 1 + 6 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/lto/pr51832.h create mode 100644 gcc/testsuite/g++.dg/lto/pr51832_0.C create mode 100644 gcc/testsuite/g++.dg/lto/pr51832_1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71df98e6699..be828596d28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-01-22 Jason Merrill + + PR c++/51832 + * varpool.c (varpool_analyze_pending_decls): Copy DECL_EXTERNAL + for extra name aliases. + 2012-01-22 Eric Botcazou PR rtl-optimization/51924 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 07b1fef7697..248578f4b17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2012-01-22 Jason Merrill + + PR c++/51832 + * g++.dg/lto/pr51832.h: New. + * g++.dg/lto/pr51832_0.C: New. + * g++.dg/lto/pr51832_1.C: New. + 2012-01-22 Eric Botcazou * gcc.dg/ext-elim-1.c: New test. diff --git a/gcc/testsuite/g++.dg/lto/pr51832.h b/gcc/testsuite/g++.dg/lto/pr51832.h new file mode 100644 index 00000000000..fee369335ed --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr51832.h @@ -0,0 +1,6 @@ +template struct A +{ + static int i; +}; + +inline void f() { A::i = 0; } diff --git a/gcc/testsuite/g++.dg/lto/pr51832_0.C b/gcc/testsuite/g++.dg/lto/pr51832_0.C new file mode 100644 index 00000000000..f8fd7ab9019 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr51832_0.C @@ -0,0 +1,7 @@ +// PR c++/51832 +// { dg-lto-do link } +// { dg-lto-options { "-std=c++11 -flto -fabi-version=2" } } + +#include "pr51832.h" + +int main() { } diff --git a/gcc/testsuite/g++.dg/lto/pr51832_1.C b/gcc/testsuite/g++.dg/lto/pr51832_1.C new file mode 100644 index 00000000000..6f0137b5812 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr51832_1.C @@ -0,0 +1 @@ +#include "pr51832.h" diff --git a/gcc/varpool.c b/gcc/varpool.c index 74fc1ba712b..e01accb21dc 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -484,6 +484,7 @@ varpool_analyze_pending_decls (void) { DECL_WEAK (node->decl) = DECL_WEAK (node->alias_of); TREE_PUBLIC (node->decl) = TREE_PUBLIC (node->alias_of); + DECL_EXTERNAL (node->decl) = DECL_EXTERNAL (node->alias_of); DECL_VISIBILITY (node->decl) = DECL_VISIBILITY (node->alias_of); if (TREE_PUBLIC (node->decl)) {