aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Austern <austern@apple.com>2003-11-06 22:08:26 +0000
committerMatt Austern <austern@gcc.gnu.org>2003-11-06 22:08:26 +0000
commit968b41a1662526b8b3eb5861f7fb369450ff9644 (patch)
treec4ffb9b377ba06be592c6688dd70529152203fd4
parent63e292b7ec0ae980f7ffa763448c81a923a72321 (diff)
downloadgcc-968b41a1662526b8b3eb5861f7fb369450ff9644.zip
gcc-968b41a1662526b8b3eb5861f7fb369450ff9644.tar.gz
gcc-968b41a1662526b8b3eb5861f7fb369450ff9644.tar.bz2
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
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/c-common.c39
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c1
-rw-r--r--gcc/cp/method.c1
-rw-r--r--gcc/cp/optimize.c1
-rw-r--r--gcc/tree.h28
-rw-r--r--gcc/varasm.c28
8 files changed, 61 insertions, 58 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d2c7fa5..f9c4da7 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 1d32d96..f587fb2d 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 a9656c1..7f83578 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 2bd6ff3..0f7a8bc 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 c6651e8..61aebd4 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 2b7df6c..7dc57ce 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 e621741..03b85df 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 21b76b9..9ee145d 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))