aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@gcc.gnu.org>2002-05-15 09:50:44 -0700
committerRichard Henderson <rth@gcc.gnu.org>2002-05-15 09:50:44 -0700
commit14285ace8899def6117605a40a2b7bacabbfb1ab (patch)
tree179f7a6574d28237262fa17ca5626ccf632f8315 /gcc/varasm.c
parentd2aa36f5d96ab2a31788516e05b4c1f3cc0503d6 (diff)
downloadgcc-14285ace8899def6117605a40a2b7bacabbfb1ab.zip
gcc-14285ace8899def6117605a40a2b7bacabbfb1ab.tar.gz
gcc-14285ace8899def6117605a40a2b7bacabbfb1ab.tar.bz2
varasm.c (merge_weak): Error for any weakening after definition.
* varasm.c (merge_weak): Error for any weakening after definition. Adjust weakening after use warning to catch more cases. (assemble_alias): Set TREE_USED and TREE_ASM_WRITTEN consistently. * config/alpha/alpha.c (alpha_encode_section_info): Do not abort. * gcc.dg/weak-5.c (vfoo1c): No warning here. (vfoo1f): Warning here. (vfoo1l): Don't redefine the alias. From-SVN: r53491
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6fb663e..05a8ada 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4830,14 +4830,6 @@ merge_weak (newdecl, olddecl)
if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
return;
- if (SUPPORTS_WEAK
- && DECL_WEAK (newdecl)
- && DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)
- && (TREE_CODE (olddecl) != VAR_DECL || ! TREE_STATIC (olddecl))
- && TREE_USED (olddecl)
- && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
- warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
-
if (DECL_WEAK (newdecl))
{
tree wd;
@@ -4848,10 +4840,26 @@ merge_weak (newdecl, olddecl)
go back and make it weak. This error cannot caught in
declare_weak because the NEWDECL and OLDDECL was not yet
been merged; therefore, TREE_ASM_WRITTEN was not set. */
- if (TREE_CODE (olddecl) == FUNCTION_DECL && TREE_ASM_WRITTEN (olddecl))
+ if (TREE_ASM_WRITTEN (olddecl))
error_with_decl (newdecl,
"weak declaration of `%s' must precede definition");
-
+
+ /* If we've already generated rtl referencing OLDDECL, we may
+ have done so in a way that will not function properly with
+ a weak symbol. */
+ else if (TREE_USED (olddecl)
+ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl))
+ /* ??? Not impossible that some platform may generate code
+ that doesn't function *at all* with incorrect declaration
+ before use. However, all known at present will assume
+ exteral and common symbols are not "local". */
+ /* ??? Probably these exceptions to the rule will just
+ confuse users about the true nature of the problem and
+ we should warn for *any* use before weakening. */
+ && ! (DECL_EXTERNAL (olddecl)
+ || DECL_COMMON (olddecl)))
+ warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
+
if (SUPPORTS_WEAK)
{
/* We put the NEWDECL on the weak_decls list at some point.
@@ -4992,7 +5000,6 @@ assemble_alias (decl, target)
#else
ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
#endif
- TREE_ASM_WRITTEN (decl) = 1;
#else /* !ASM_OUTPUT_DEF */
#if defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
if (! DECL_WEAK (decl))
@@ -5003,11 +5010,14 @@ assemble_alias (decl, target)
#else
ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
#endif
- TREE_ASM_WRITTEN (decl) = 1;
#else
warning ("alias definitions not supported in this configuration; ignored");
#endif
#endif
+
+ TREE_USED (decl) = 1;
+ TREE_ASM_WRITTEN (decl) = 1;
+ TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1;
}
/* Emit an assembler directive to set symbol for DECL visibility to