diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ea3f35..94e48a5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2002-11-26 Richard Henderson <rth@redhat.com> + + * c-common.c (handle_visibility_attribute): Accept "default". + * tree.h (enum symbol_visibility): New. + (decl_visibility): Declare. + * target.h (gcc_target.visibility): Take visibility arg as integer. + * varasm.c (default_assemble_visibility): Likewise. + (decl_visibility): New. + (maybe_assemble_visibility): Use it. + * output.h (default_assemble_visibility): Update prototype. + * config/rs6000/rs6000.c (rs6000_assemble_visibility): Take + visibility arg as integer. + 2002-11-26 Kazu Hirata <kazu@cs.umass.edu> * config/h8300/h8300.c: Adjust spacing. diff --git a/gcc/c-common.c b/gcc/c-common.c index 286f3b0..f32456d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5891,9 +5891,10 @@ handle_visibility_attribute (node, name, args, flags, no_add_attrs) } if (strcmp (TREE_STRING_POINTER (id), "hidden") && strcmp (TREE_STRING_POINTER (id), "protected") - && strcmp (TREE_STRING_POINTER (id), "internal")) + && strcmp (TREE_STRING_POINTER (id), "internal") + && strcmp (TREE_STRING_POINTER (id), "default")) { - error ("visibility arg must be one of \"hidden\", \"protected\" or \"internal\""); + error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\""); *no_add_attrs = true; return NULL_TREE; } diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 7d79dd8..bb9dcff 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -186,7 +186,7 @@ static int constant_pool_expr_1 PARAMS ((rtx, int *, int *)); static struct machine_function * rs6000_init_machine_status PARAMS ((void)); static bool rs6000_assemble_integer PARAMS ((rtx, unsigned int, int)); #ifdef HAVE_GAS_HIDDEN -static void rs6000_assemble_visibility PARAMS ((tree, const char *)); +static void rs6000_assemble_visibility PARAMS ((tree, int)); #endif static int rs6000_ra_ever_killed PARAMS ((void)); static tree rs6000_handle_longcall_attribute PARAMS ((tree *, tree, tree, int, bool *)); @@ -8157,23 +8157,29 @@ rs6000_assemble_integer (x, size, aligned_p) VISIBILITY_TYPE. */ static void -rs6000_assemble_visibility (decl, visibility_type) +rs6000_assemble_visibility (decl, vis) tree decl; - const char *visibility_type; + int vis; { - default_assemble_visibility (decl, visibility_type); - /* Functions need to have their entry point symbol visibility set as well as their descriptor symbol visibility. */ if (DEFAULT_ABI == ABI_AIX && TREE_CODE (decl) == FUNCTION_DECL) { - const char *name; + static const char * const visibility_types[] = { + NULL, "internal", "hidden", "protected" + }; + + const char *name, *type; name = ((* targetm.strip_name_encoding) (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); + type = visibility_types[vis]; - fprintf (asm_out_file, "\t.%s\t.%s\n", visibility_type, name); + fprintf (asm_out_file, "\t.%s\t%s\n", type, name); + fprintf (asm_out_file, "\t.%s\t.%s\n", type, name); } + else + default_assemble_visibility (decl, vis); } #endif diff --git a/gcc/output.h b/gcc/output.h index 4070f95..dd2e4d6 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -253,7 +253,7 @@ extern void assemble_constant_align PARAMS ((tree)); extern void assemble_alias PARAMS ((tree, tree)); -extern void default_assemble_visibility PARAMS ((tree, const char *)); +extern void default_assemble_visibility PARAMS ((tree, int)); /* Output a string of literal assembler code for an `asm' keyword used between functions. */ diff --git a/gcc/target.h b/gcc/target.h index 161c3dd..d947562 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -74,7 +74,7 @@ struct gcc_target /* Emit an assembler directive to set visibility for the symbol associated with the tree decl. */ - void (* visibility) PARAMS ((tree, const char *)); + void (* visibility) PARAMS ((tree, int)); /* Output the assembler code for entry to a function. */ void (* function_prologue) PARAMS ((FILE *, HOST_WIDE_INT)); diff --git a/gcc/tree.h b/gcc/tree.h index b020ece..abe0703 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2133,6 +2133,16 @@ enum tls_model { }; extern enum tls_model flag_tls_default; + +/* Enumerate visibility settings. */ + +enum symbol_visibility +{ + VISIBILITY_DEFAULT, + VISIBILITY_INTERNAL, + VISIBILITY_HIDDEN, + VISIBILITY_PROTECTED +}; /* A pointer-to-function member type looks like: @@ -3043,6 +3053,7 @@ extern void make_decl_one_only PARAMS ((tree)); extern int supports_one_only PARAMS ((void)); extern void variable_section PARAMS ((tree, int)); enum tls_model decl_tls_model PARAMS ((tree)); +enum symbol_visibility decl_visibility PARAMS ((tree)); /* In fold-const.c */ extern int div_and_round_double PARAMS ((enum tree_code, int, diff --git a/gcc/varasm.c b/gcc/varasm.c index db7599e..2ac3da5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4643,20 +4643,25 @@ assemble_alias (decl, target) } /* Emit an assembler directive to set symbol for DECL visibility to - VISIBILITY_TYPE. */ + the visibility type VIS, which must not be VISIBILITY_DEFAULT. */ void -default_assemble_visibility (decl, visibility_type) +default_assemble_visibility (decl, vis) tree decl; - const char *visibility_type ATTRIBUTE_UNUSED; + int vis; { - const char *name; + static const char * const visibility_types[] = { + NULL, "internal", "hidden", "protected" + }; + + const char *name, *type; name = (* targetm.strip_name_encoding) (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); + type = visibility_types[vis]; #ifdef HAVE_GAS_HIDDEN - fprintf (asm_out_file, "\t.%s\t%s\n", visibility_type, name); + fprintf (asm_out_file, "\t.%s\t%s\n", type, name); #else warning ("visibility attribute not supported in this configuration; ignored"); #endif @@ -4668,13 +4673,10 @@ 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))); - (* targetm.asm_out.visibility) (decl, type); - } + enum symbol_visibility vis = decl_visibility (decl); + + if (vis != VISIBILITY_DEFAULT) + (* targetm.asm_out.visibility) (decl, vis); } /* Returns 1 if the target configuration supports defining public symbols @@ -4775,6 +4777,31 @@ decl_tls_model (decl) return kind; } +enum symbol_visibility +decl_visibility (decl) + tree decl; +{ + tree attr = lookup_attribute ("visibility", DECL_ATTRIBUTES (decl)); + + if (attr) + { + const char *which = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))); + + if (strcmp (which, "default") == 0) + return VISIBILITY_DEFAULT; + if (strcmp (which, "internal") == 0) + return VISIBILITY_INTERNAL; + if (strcmp (which, "hidden") == 0) + return VISIBILITY_HIDDEN; + if (strcmp (which, "protected") == 0) + return VISIBILITY_PROTECTED; + + abort (); + } + + return VISIBILITY_DEFAULT; +} + /* Select a set of attributes for section NAME based on the properties of DECL and whether or not RELOC indicates that DECL's initializer might contain runtime relocations.