/* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
- Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GCC.
}
if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
- && !DECL_WEAK (decl) /* don't complain about a redundant #pragma */
+ && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma. */
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
- warning ("%Happlying #pragma weak '%D' after first use results "
- "in unspecified behavior", &DECL_SOURCE_LOCATION (decl), decl);
+ warning ("%Japplying #pragma weak '%D' after first use results "
+ "in unspecified behavior", decl, decl);
declare_weak (decl);
}
{
tree *p, t, id;
- /* Copied from the check in set_decl_assembler_name. */
- if (TREE_CODE (decl) == FUNCTION_DECL
- || (TREE_CODE (decl) == VAR_DECL
- && (TREE_STATIC (decl)
- || DECL_EXTERNAL (decl)
- || TREE_PUBLIC (decl))))
- id = DECL_ASSEMBLER_NAME (decl);
- else
+ /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed. */
+
+ /* No weak symbols pending, take the short-cut. */
+ if (!pending_weaks)
+ return;
+ /* If it's not visible outside this file, it doesn't matter whether
+ it's weak. */
+ if (!DECL_EXTERNAL (decl) && !TREE_PUBLIC (decl))
+ return;
+ /* If it's not a function or a variable, it can't be weak.
+ FIXME: what kinds of things are visible outside this file but
+ aren't functions or variables? Should this be an abort() instead? */
+ if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
return;
+ id = DECL_ASSEMBLER_NAME (decl);
+
for (p = &pending_weaks; (t = *p) ; p = &TREE_CHAIN (t))
if (id == TREE_PURPOSE (t))
{
static GTY(()) tree pending_redefine_extname;
-#ifdef HANDLE_PRAGMA_REDEFINE_EXTNAME
static void handle_pragma_redefine_extname (cpp_reader *);
/* #pragma redefined_extname oldname newname */
warning ("junk at end of #pragma redefine_extname");
decl = identifier_global_value (oldname);
- if (decl && TREE_CODE_CLASS (TREE_CODE (decl)) == 'd')
+ if (decl && (TREE_CODE (decl) == FUNCTION_DECL
+ || TREE_CODE (decl) == VAR_DECL))
{
if (DECL_ASSEMBLER_NAME_SET_P (decl)
&& DECL_ASSEMBLER_NAME (decl) != newname)
warning ("#pragma redefine_extname conflicts with declaration");
- SET_DECL_ASSEMBLER_NAME (decl, newname);
+ change_decl_assembler_name (decl, newname);
}
else
add_to_renaming_pragma_list(oldname, newname);
}
-#endif
void
add_to_renaming_pragma_list (tree oldname, tree newname)
#endif
#ifdef HANDLE_PRAGMA_REDEFINE_EXTNAME
c_register_pragma (0, "redefine_extname", handle_pragma_redefine_extname);
+#else
+ if (flag_mudflap)
+ c_register_pragma (0, "redefine_extname", handle_pragma_redefine_extname);
#endif
#ifdef HANDLE_PRAGMA_EXTERN_PREFIX
c_register_pragma (0, "extern_prefix", handle_pragma_extern_prefix);