diff options
author | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-06 22:08:26 +0000 |
---|---|---|
committer | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-06 22:08:26 +0000 |
commit | 9c40570af36d485a0b1b2cf8c5d0dc3a047cfaaa (patch) | |
tree | c4ffb9b377ba06be592c6688dd70529152203fd4 | |
parent | 5772d010eebef46859ae8e17830217b02548d970 (diff) | |
download | gcc-9c40570af36d485a0b1b2cf8c5d0dc3a047cfaaa.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73320 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/c-common.c | 39 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 1 | ||||
-rw-r--r-- | gcc/cp/method.c | 1 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 1 | ||||
-rw-r--r-- | gcc/tree.h | 28 | ||||
-rw-r--r-- | gcc/varasm.c | 28 |
8 files changed, 61 insertions, 58 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2c7fa58054..f9c4da7350d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +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 diff --git a/gcc/c-common.c b/gcc/c-common.c index 1d32d963a51..f587fb2df63 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a9656c15d53..7f83578b137 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2bd6ff335bc..0f7a8bcf62b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index c6651e84880..61aebd4bbd4 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -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) { diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 2b7df6c5244..7dc57ce31a3 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -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); diff --git a/gcc/tree.h b/gcc/tree.h index e6217413e90..03b85dfc501 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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); diff --git a/gcc/varasm.c b/gcc/varasm.c index 21b76b9a59c..9ee145db387 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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)) |