+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
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
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)
/* 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)
{
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);
#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)
(! 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(())
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;
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 (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);
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);
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.
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))