This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto][patch] Small fix for the handling of weak decls
- From: Rafael Espindola <espindola at google dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Tue, 9 Dec 2008 17:16:03 +0000
- Subject: [lto][patch] Small fix for the handling of weak decls
If we see first a WEAKUNDEF and then a WEAKDEF, we should use the
second. Also, the resolution of WEAKUNDEF should be LDPR_RESOLVED_IR.
2008-12-09 Rafael Avila de Espindola <espindola@google.com>
* lto-function-in.c (get_resolution): Fix handling of weak decls.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto-function-in.c b/gcc/lto-function-in.c
index 5c62247..5c12d7c 100644
--- a/gcc/lto-function-in.c
+++ b/gcc/lto-function-in.c
@@ -2827,10 +2827,16 @@ get_resolution (struct data_in *data_in, unsigned index)
be the prevailing definition. */
if (DECL_WEAK (t))
{
+ tree prevailing_decl;
+ if (DECL_EXTERNAL (t))
+ return LDPR_RESOLVED_IR;
+
/* If this is the first time we see T, it won't have a
prevailing definition yet. */
- tree prevailing_decl = lto_symtab_prevailing_decl (t);
- if (prevailing_decl == t || prevailing_decl == NULL_TREE)
+ prevailing_decl = lto_symtab_prevailing_decl (t);
+ if (prevailing_decl == t
+ || prevailing_decl == NULL_TREE
+ || DECL_EXTERNAL (prevailing_decl))
return LDPR_PREVAILING_DEF;
else
return LDPR_PREEMPTED_IR;