Commit 968b41a1 by Matt Austern Committed by Matt Austern

c-common.c (handle_visibility_attribute): Set DECL_VISIBILITY field instead of…

c-common.c (handle_visibility_attribute): Set DECL_VISIBILITY field instead of hanging an attribute object off the decl.

	* c-common.c (handle_visibility_attribute): Set DECL_VISIBILITY
	field instead of hanging an attribute object off the decl.
	* tree.h (DECL_VISIBLITY): New accessor macro for
	symbol_visibility field in struct tree_decl.
	(enum symbol_visibility): Move definition to before tree_decl.
	(struct tree_decl): Define new two-bit field, symbol_visibility.
	(decl_visibility): Remove declaration.
	* varasm.c (maybe_assemble_visibility): Use DECL_VISIBILITY
	instead of decl_visibility.
	(default_binds_local_p_1):  Use DECL_VISIBILITY	instead of
	decl_visibility.
	(decl_visibility): Remove.
	* cp/decl.c (duplicate_decls): copy DECL_VISIBILITY field.
	* cp/method.c (use_thunk): give thunk same visibility as function.
	* cp/optimize.c (maybe_clone_body): copy DECL_VISIBILITY field.

From-SVN: r73320
parent 63e292b7
2003-11-06 Matt Austern <austern@apple.com>
* c-common.c (handle_visibility_attribute): Set DECL_VISIBILITY
field instead of hanging an attribute object off the decl.
* tree.h (DECL_VISIBLITY): New accessor macro for
symbol_visibility field in struct tree_decl.
(enum symbol_visibility): Move definition to before tree_decl.
(struct tree_decl): Define new two-bit field, symbol_visibility.
(decl_visibility): Remove declaration.
* varasm.c (maybe_assemble_visibility): Use DECL_VISIBILITY
instead of decl_visibility.
(default_binds_local_p_1): Use DECL_VISIBILITY instead of
decl_visibility.
(decl_visibility): Remove.
2003-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* config/s390/s390.c (s390_emit_epilogue): Recognize more cases
......
......@@ -4929,34 +4929,33 @@ handle_visibility_attribute (tree *node, tree name, tree args,
bool *no_add_attrs)
{
tree decl = *node;
tree id = TREE_VALUE (args);
*no_add_attrs = true;
if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl))
{
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
*no_add_attrs = true;
return NULL_TREE;
}
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")
&& strcmp (TREE_STRING_POINTER (id), "default"))
{
error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
*no_add_attrs = true;
return NULL_TREE;
}
if (TREE_CODE (id) != STRING_CST)
{
error ("visibility arg not a string");
return NULL_TREE;
}
if (strcmp (TREE_STRING_POINTER (id), "default") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
else if (strcmp (TREE_STRING_POINTER (id), "internal") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_INTERNAL;
else if (strcmp (TREE_STRING_POINTER (id), "hidden") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
else if (strcmp (TREE_STRING_POINTER (id), "protected") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_PROTECTED;
else
error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
return NULL_TREE;
}
......
2003-11-06 Matt Austern <austern@apple.com>
* decl.c (duplicate_decls): copy DECL_VISIBILITY field.
* method.c (use_thunk): give thunk same visibility as function.
* optimize.c (maybe_clone_body): copy DECL_VISIBILITY field.
2003-11-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/11616
......
......@@ -1850,6 +1850,7 @@ duplicate_decls (tree newdecl, tree olddecl)
TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
if (TREE_CODE (newdecl) == FUNCTION_DECL)
......
......@@ -383,6 +383,7 @@ use_thunk (tree thunk_fndecl, bool emit_p)
/* The linkage of the function may have changed. FIXME in linkage
rewrite. */
TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
if (flag_syntax_only)
{
......
......@@ -158,6 +158,7 @@ maybe_clone_body (tree fn)
DECL_INTERFACE_KNOWN (clone) = DECL_INTERFACE_KNOWN (fn);
DECL_NOT_REALLY_EXTERN (clone) = DECL_NOT_REALLY_EXTERN (fn);
TREE_PUBLIC (clone) = TREE_PUBLIC (fn);
DECL_VISIBILITY (clone) = DECL_VISIBILITY (fn);
/* Adjust the parameter names and locations. */
parm = DECL_ARGUMENTS (fn);
......
......@@ -1491,6 +1491,9 @@ struct tree_type GTY(())
#define DECL_DECLARED_INLINE_P(NODE) \
(FUNCTION_DECL_CHECK (NODE)->decl.declared_inline_flag)
/* Value of the decls's visibility attribute */
#define DECL_VISIBILITY(NODE) (DECL_CHECK (NODE)->decl.visibility)
/* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */
#define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable)
......@@ -1631,6 +1634,16 @@ struct tree_type GTY(())
(! DECL_CONTEXT (EXP) \
|| TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
/* Enumerate visibility settings. */
enum symbol_visibility
{
VISIBILITY_DEFAULT,
VISIBILITY_INTERNAL,
VISIBILITY_HIDDEN,
VISIBILITY_PROTECTED
};
struct function;
struct tree_decl GTY(())
......@@ -1672,8 +1685,9 @@ struct tree_decl GTY(())
unsigned uninlinable : 1;
unsigned thread_local_flag : 1;
unsigned declared_inline_flag : 1;
unsigned unused : 3;
/* three unused bits. */
ENUM_BITFIELD(symbol_visibility) visibility : 2;
unsigned unused : 1;
/* one unused bit. */
unsigned lang_flag_0 : 1;
unsigned lang_flag_1 : 1;
......@@ -2007,15 +2021,6 @@ 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:
......@@ -2969,7 +2974,6 @@ extern void make_decl_one_only (tree);
extern int supports_one_only (void);
extern void variable_section (tree, int);
enum tls_model decl_tls_model (tree);
enum symbol_visibility decl_visibility (tree);
extern void resolve_unique_section (tree, int, int);
extern void mark_referenced (tree);
extern void notice_global_symbol (tree);
......
......@@ -4430,7 +4430,7 @@ default_assemble_visibility (tree decl, int vis)
static void
maybe_assemble_visibility (tree decl)
{
enum symbol_visibility vis = decl_visibility (decl);
enum symbol_visibility vis = DECL_VISIBILITY (decl);
if (vis != VISIBILITY_DEFAULT)
(* targetm.asm_out.visibility) (decl, vis);
......@@ -4532,30 +4532,6 @@ decl_tls_model (tree decl)
return kind;
}
enum symbol_visibility
decl_visibility (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.
......@@ -5131,7 +5107,7 @@ default_binds_local_p_1 (tree exp, int shlib)
else if (! TREE_PUBLIC (exp))
local_p = true;
/* A variable is local if the user tells us so. */
else if (decl_visibility (exp) != VISIBILITY_DEFAULT)
else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
local_p = true;
/* Otherwise, variables defined outside this object may not be local. */
else if (DECL_EXTERNAL (exp))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment