From 47bd70b56aa4ccc10fd0e90a7fae4c94d991bb30 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 26 Feb 2002 22:17:22 +0100 Subject: 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 --- gcc/attribs.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'gcc/attribs.c') 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. */ -- cgit v1.2.1