* attribs.c (handle_alias_attribute): Don't call assemble_alias.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Mar 2002 04:50:53 +0000 (04:50 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Mar 2002 04:50:53 +0000 (04:50 +0000)
        (handle_visibility_attribute): Don't call assemble_visibility.
        * toplev.c (rest_of_decl_compilation): Invoke make_decl_rtl even
        without asmspec.  Invoke assemble_alias when needed.
        * varasm.c (maybe_assemble_visibility): New.
        (assemble_start_function, assemble_variable, assemble_alias): Use it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50237 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/attribs.c
gcc/toplev.c
gcc/varasm.c

index 85872bb..410c2cf 100644 (file)
@@ -1,5 +1,14 @@
 2002-03-02  Richard Henderson  <rth@redhat.com>
 
+       * attribs.c (handle_alias_attribute): Don't call assemble_alias.
+       (handle_visibility_attribute): Don't call assemble_visibility.
+       * toplev.c (rest_of_decl_compilation): Invoke make_decl_rtl even
+       without asmspec.  Invoke assemble_alias when needed.
+       * varasm.c (maybe_assemble_visibility): New.
+       (assemble_start_function, assemble_variable, assemble_alias): Use it.
+
+2002-03-02  Richard Henderson  <rth@redhat.com>
+
        * varasm.c (make_decl_rtl): Remove call to REDO_SECTION_INFO_P;
        invoke ENCODE_SECTION_INFO with first call flag.
 
index 2879d10..ca5a10c 100644 (file)
@@ -1054,7 +1054,6 @@ handle_alias_attribute (node, name, args, flags, no_add_attrs)
        DECL_INITIAL (decl) = error_mark_node;
       else
        DECL_EXTERNAL (decl) = 0;
-      assemble_alias (decl, id);
     }
   else
     {
@@ -1102,8 +1101,6 @@ handle_visibility_attribute (node, name, args, flags, no_add_attrs)
          *no_add_attrs = true;
          return NULL_TREE;
        }
-
-      assemble_visibility (decl, TREE_STRING_POINTER (id));
     }
 
   return NULL_TREE;
index 7460582..1767fb4 100644 (file)
@@ -2254,17 +2254,33 @@ rest_of_decl_compilation (decl, asmspec, top_level, at_end)
 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
 #endif
 
+  /* We deferred calling assemble_alias so that we could collect
+     other attributes such as visibility.  Emit the alias now.  */
+  {
+    tree alias;
+    alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
+    if (alias)
+      {
+       alias = TREE_VALUE (TREE_VALUE (alias));
+       alias = get_identifier (TREE_STRING_POINTER (alias));
+        assemble_alias (decl, alias);
+      }
+  }
+
   /* Forward declarations for nested functions are not "external",
      but we need to treat them as if they were.  */
   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
       || TREE_CODE (decl) == FUNCTION_DECL)
     {
       timevar_push (TV_VARCONST);
-      if (asmspec)
-       make_decl_rtl (decl, asmspec);
-      /* Don't output anything
-        when a tentative file-scope definition is seen.
-        But at end of compilation, do output code for them.  */
+
+      /* If asmspec non-zero, we may be creating a global register variable.
+        If asmspec zero, we may be making sure that ENCODE_SECTION_INFO is
+        up-to-date.  */
+      make_decl_rtl (decl, asmspec);
+
+      /* Don't output anything when a tentative file-scope definition
+        is seen.  But at end of compilation, do output code for them.  */
       if (at_end || !DECL_DEFER_OUTPUT (decl))
        assemble_variable (decl, top_level, at_end, 0);
       if (decl == last_assemble_variable_decl)
@@ -2272,6 +2288,7 @@ rest_of_decl_compilation (decl, asmspec, top_level, at_end)
          ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl,
                                     top_level, at_end);
        }
+
       timevar_pop (TV_VARCONST);
     }
   else if (DECL_REGISTER (decl) && asmspec != 0)
index 4d57b89..187429e 100644 (file)
@@ -171,6 +171,7 @@ static void mark_weak_decls         PARAMS ((void *));
 #if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
 static void remove_from_pending_weak_list      PARAMS ((const char *));
 #endif
+static void maybe_assemble_visibility  PARAMS ((tree));
 static int in_named_entry_eq           PARAMS ((const PTR, const PTR));
 static hashval_t in_named_entry_hash   PARAMS ((const PTR));
 #ifdef ASM_OUTPUT_BSS
@@ -1252,6 +1253,8 @@ assemble_start_function (decl, fnname)
       else
 #endif
       ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
+
+      maybe_assemble_visibility (decl);
     }
 
   /* Do any machine/system dependent processing of the function name */
@@ -1603,6 +1606,9 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
   DECL_ALIGN (decl) = align;
   set_mem_align (decl_rtl, align);
 
+  if (TREE_PUBLIC (decl))
+    maybe_assemble_visibility (decl);
+
   /* Handle uninitialized definitions.  */
 
   if ((DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node
@@ -5181,6 +5187,8 @@ assemble_alias (decl, target)
       else
 #endif
        ASM_GLOBALIZE_LABEL (asm_out_file, name);
+
+      maybe_assemble_visibility (decl);
     }
 
 #ifdef ASM_OUTPUT_DEF_FROM_DECLS
@@ -5225,6 +5233,21 @@ assemble_visibility (decl, visibility_type)
 #endif
 }
 
+/* A helper function to call assemble_visibility when needed for a decl.  */
+
+static void
+maybe_assemble_visibility (decl)
+     tree decl;
+{
+  tree visibility = lookup_attribute ("visibility", DECL_ATTRIBUTES (decl));
+  if (visibility)
+    {
+      const char *type
+       = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (visibility)));
+      assemble_visibility (decl, type);
+    }
+}
+
 /* Returns 1 if the target configuration supports defining public symbols
    so that one of them will be chosen at link time instead of generating a
    multiply-defined symbol error, whether through the use of weak symbols or