+2002-04-28 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ PR c/6343
+ * c-decl.c (duplicate_decls): Call merge_weak.
+ * c-pragma.c (apply_pragma_weak): Warn about misuse.
+ * output.h (merge_weak): Prototype merge_weak.
+ * varasm.c (merge_weak): New function.
+ (declare_weak): Make sure we don't give an error on VAR_DECLs.
+ Mark RTL with SYMBOL_REF_WEAK.
+
2002-04-25 David S. Miller <davem@redhat.com>
PR target/6422
}
/* Merge the storage class information. */
- DECL_WEAK (newdecl) |= DECL_WEAK (olddecl);
+ merge_weak (newdecl, olddecl);
+
/* For functions, static overrides non-static. */
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
decl_attributes (&decl, build_tree_list (get_identifier ("alias"),
build_tree_list (NULL, value)),
0);
+ if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
+ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+ warning_with_decl (decl, "applying #pragma weak `%s' after first use results in unspecified behavior");
+
declare_weak (decl);
}
+2002-04-28 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ PR c/6343
+ * decl.c (duplicate_decls): Call merge_weak.
+
2002-04-26 Mark Mitchell <mark@codesourcery.com>
PR c++/6497
}
/* Merge the storage class information. */
- DECL_WEAK (newdecl) |= DECL_WEAK (olddecl);
+ merge_weak (newdecl, olddecl);
+
DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
/* Declare DECL to be a weak symbol. */
extern void declare_weak PARAMS ((tree));
+/* Merge weak status. */
+extern void merge_weak PARAMS ((tree, tree));
#endif /* TREE_CODE */
/* Emit any pending weak declarations. */
+2002-04-28 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ PR c/6343
+ * gcc.dg/weak-[2-7].c: New tests.
+
2002-04-26 Mark Mitchell <mark@codesourcery.com>
PR c++/6497
to be emitted. */
static tree weak_decls;
+/* Merge weak status between NEWDECL and OLDDECL. */
+
+void
+merge_weak (newdecl, olddecl)
+ tree newdecl;
+ tree olddecl;
+{
+ tree decl;
+
+ if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
+ return;
+
+ decl = DECL_WEAK (olddecl) ? newdecl : olddecl;
+
+ if (SUPPORTS_WEAK
+ && DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)
+ && (TREE_CODE (decl) != VAR_DECL
+ || ! TREE_STATIC (decl))
+ && TREE_USED (decl)
+ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+ warning_with_decl (decl, "weak declaration of `%s' after first use results in unspecified behavior");
+
+ declare_weak (decl);
+}
+
/* Declare DECL to be a weak symbol. */
void
{
if (! TREE_PUBLIC (decl))
error_with_decl (decl, "weak declaration of `%s' must be public");
- else if (TREE_ASM_WRITTEN (decl))
+ else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
error_with_decl (decl, "weak declaration of `%s' must precede definition");
else if (SUPPORTS_WEAK)
{
warning_with_decl (decl, "weak declaration of `%s' not supported");
DECL_WEAK (decl) = 1;
+
+ if (DECL_RTL_SET_P (decl)
+ && GET_CODE (DECL_RTL (decl)) == MEM
+ && XEXP (DECL_RTL (decl), 0)
+ && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
+ SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
}
/* Emit any pending weak declarations. */