PR c++/20961
* varasm.c (merge_weak): Remove NEWDECL from WEAK_DECLS chain
if both NEWDECL and OLDDECL are already weak.
* g++.dg/ext/weak3.C: New test.
From-SVN: r99306
+2005-05-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/20961
+ * varasm.c (merge_weak): Remove NEWDECL from WEAK_DECLS chain
+ if both NEWDECL and OLDDECL are already weak.
+
2005-05-06 Richard Sandiford <rsandifo@redhat.com>
* config/rs6000/sysv4.h (EXTRA_SUBTARGET_SWITCHES): Delete.
+2005-05-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/20961
+ * g++.dg/ext/weak3.C: New test.
+
2005-05-05 Mark Mitchell <mark@codesourcery.com>
PR c++/21352
--- /dev/null
+// PR c++/20961
+// Test for #pragma weak and __attribute__((weak)) being used together.
+// { dg-do compile }
+// { dg-require-weak "" }
+// { dg-options "" }
+
+// { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?_Z3foov" } }
+
+int foo ();
+#pragma weak foo
+
+int
+__attribute__((weak))
+foo ()
+{
+ return 0;
+}
merge_weak (tree newdecl, tree olddecl)
{
if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
- return;
+ {
+ if (DECL_WEAK (newdecl) && SUPPORTS_WEAK)
+ {
+ tree *pwd;
+ /* We put the NEWDECL on the weak_decls list at some point
+ and OLDDECL as well. Keep just OLDDECL on the list. */
+ for (pwd = &weak_decls; *pwd; pwd = &TREE_CHAIN (*pwd))
+ if (TREE_VALUE (*pwd) == newdecl)
+ {
+ *pwd = TREE_CHAIN (*pwd);
+ break;
+ }
+ }
+ return;
+ }
if (DECL_WEAK (newdecl))
{