aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-11-26 22:13:23 -0800
committerRichard Henderson <rth@gcc.gnu.org>2002-11-26 22:13:23 -0800
commit25fdb4dc9751240a83e919d089afd9129f1b0396 (patch)
tree81aceb060743bb202f3bdc25d65782869844092b /gcc/varasm.c
parent02077425b78dddfa059082e3e2b243fbc4c2fd6a (diff)
downloadgcc-25fdb4dc9751240a83e919d089afd9129f1b0396.zip
gcc-25fdb4dc9751240a83e919d089afd9129f1b0396.tar.gz
gcc-25fdb4dc9751240a83e919d089afd9129f1b0396.tar.bz2
c-common.c (handle_visibility_attribute): Accept "default".
* 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
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c51
1 files changed, 39 insertions, 12 deletions
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.