summaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-02-26 22:17:22 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2002-02-26 22:17:22 +0100
commit47bd70b56aa4ccc10fd0e90a7fae4c94d991bb30 (patch)
treebf177b7375ac3fceb1bd51f1f20b2ff845e3fbba /gcc/attribs.c
parent6d73371a68e805956981592bdc2a631acaab2a33 (diff)
downloadgcc-47bd70b56aa4ccc10fd0e90a7fae4c94d991bb30.tar.gz
attribs.c (c_common_attribute_table): Add visibility.
* attribs.c (c_common_attribute_table): Add visibility. (handle_visibility_attribute): New function. * varasm.c (assemble_visibility): New function. * output.h (assemble_visibility): Add prototype. * tree.h (MODULE_LOCAL_P): Define. * crtstuff.c (__dso_handle): Use visibility attribute. * config/i386/i386.h (ENCODE_SECTION_INFO): Set SYMBOL_REF_FLAG for MODULE_LOCAL_P symbols too. * config/ia64/ia64.c (ia64_encode_section_info): Handle MODULE_LOCAL_P symbols the same way as local symbols. Add SDATA_NAME_FLAG_CHAR even if decl was explicitely forced into .sdata/.sbss by the user. * doc/extend.texi (Function Attributes): Document visibility attribute. * gcc.dg/ia64-visibility-1.c: New test. From-SVN: r50061
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index d046a6242ba..2879d100a30 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -75,6 +75,8 @@ static tree handle_weak_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree handle_alias_attribute PARAMS ((tree *, tree, tree, int,
bool *));
+static tree handle_visibility_attribute PARAMS ((tree *, tree, tree, int,
+ bool *));
static tree handle_no_instrument_function_attribute PARAMS ((tree *, tree,
tree, int,
bool *));
@@ -148,6 +150,8 @@ static const struct attribute_spec c_common_attribute_table[] =
handle_deprecated_attribute },
{ "vector_size", 1, 1, false, true, false,
handle_vector_size_attribute },
+ { "visibility", 1, 1, true, false, false,
+ handle_visibility_attribute },
{ NULL, 0, 0, false, false, false, NULL }
};
@@ -1061,6 +1065,50 @@ handle_alias_attribute (node, name, args, flags, no_add_attrs)
return NULL_TREE;
}
+/* Handle an "visibility" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_visibility_attribute (node, name, args, flags, no_add_attrs)
+ tree *node;
+ tree name;
+ tree args;
+ int flags ATTRIBUTE_UNUSED;
+ bool *no_add_attrs;
+{
+ tree decl = *node;
+
+ if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl))
+ {
+ warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
+ *no_add_attrs = true;
+ }
+ else
+ {
+ tree id;
+
+ id = TREE_VALUE (args);
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("visibility arg not a string");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ if (strcmp (TREE_STRING_POINTER (id), "hidden")
+ && strcmp (TREE_STRING_POINTER (id), "protected")
+ && strcmp (TREE_STRING_POINTER (id), "internal"))
+ {
+ error ("visibility arg must be one of \"hidden\", \"protected\" or \"internal\"");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ assemble_visibility (decl, TREE_STRING_POINTER (id));
+ }
+
+ return NULL_TREE;
+}
+
/* Handle a "no_instrument_function" attribute; arguments as in
struct attribute_spec.handler. */