* 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.
From-SVN: r59559
+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.
}
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;
}
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 *));
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
\f
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. */
/* 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));
};
extern enum tls_model flag_tls_default;
+
+/* Enumerate visibility settings. */
+
+enum symbol_visibility
+{
+ VISIBILITY_DEFAULT,
+ VISIBILITY_INTERNAL,
+ VISIBILITY_HIDDEN,
+ VISIBILITY_PROTECTED
+};
\f
/* A pointer-to-function member type looks like:
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,
}
/* 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
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
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.