aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-pragma.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-pragma.c')
-rw-r--r--gcc/c-pragma.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c
index 4c43baa9b0d..819e6965bd6 100644
--- a/gcc/c-pragma.c
+++ b/gcc/c-pragma.c
@@ -288,15 +288,22 @@ maybe_apply_pragma_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))
@@ -447,7 +454,7 @@ maybe_apply_renaming_pragma (decl, asmname)
{
const char *oldasmname = IDENTIFIER_POINTER (oldname) + 1;
if (asmname && strcmp (TREE_STRING_POINTER (asmname), oldasmname) != 0)
- warning ("asm declaration conficts with previous rename");
+ warning ("asm declaration conflicts with previous rename");
asmname = build_string (strlen (oldasmname), oldasmname);
}