From: Richard Henderson Date: Fri, 27 Aug 2004 00:27:24 +0000 (-0700) Subject: tree.c (staticp): Return the static object. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=525c6bf5a6b91fa09f57b79bad9737ab3733601d;p=gcc.git tree.c (staticp): Return the static object. * tree.c (staticp): Return the static object. * tree.h (staticp): Update decl. * langhooks.h (struct lang_hooks): Change staticp return type to tree. * langhooks.c (lhd_staticp): Return NULL_TREE. * langhooks-def.h (lhd_staticp): Update decl. * c-common.c (c_staticp): Return the static object. * c-common.h (c_staticp): Update decl. From-SVN: r86650 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 802f45c013d..cf1dc09c719 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2004-08-26 Richard Henderson + + * tree.c (staticp): Return the static object. + * tree.h (staticp): Update decl. + * langhooks.h (struct lang_hooks): Change staticp return type to tree. + * langhooks.c (lhd_staticp): Return NULL_TREE. + * langhooks-def.h (lhd_staticp): Update decl. + * c-common.c (c_staticp): Return the static object. + * c-common.h (c_staticp): Update decl. + 2004-08-26 Richard Henderson * config/alpha/alpha.h (HARD_REGNO_MODE_OK): Allow complex float diff --git a/gcc/c-common.c b/gcc/c-common.c index 7e691660ac4..8b7ee2c94ea 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3828,13 +3828,12 @@ c_expand_expr (tree exp, rtx target, enum machine_mode tmode, /* Hook used by staticp to handle language-specific tree codes. */ -bool +tree c_staticp (tree exp) { - if (TREE_CODE (exp) == COMPOUND_LITERAL_EXPR - && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp))) - return true; - return false; + return (TREE_CODE (exp) == COMPOUND_LITERAL_EXPR + && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp)) + ? exp : NULL); } diff --git a/gcc/c-common.h b/gcc/c-common.h index 1c9286ef7b7..94f3249b21b 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -840,7 +840,7 @@ extern int vector_types_convertible_p (tree t1, tree t2); extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *); -extern bool c_staticp (tree); +extern tree c_staticp (tree); extern int c_common_unsafe_for_reeval (tree); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 06e3c021fd6..087fe419dae 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -50,7 +50,7 @@ extern tree lhd_return_null_tree_v (void); extern tree lhd_return_null_tree (tree); extern tree lhd_do_nothing_iii_return_null_tree (int, int, int); extern int lhd_safe_from_p (rtx, tree); -extern bool lhd_staticp (tree); +extern tree lhd_staticp (tree); extern void lhd_print_tree_nothing (FILE *, tree, int); extern const char *lhd_decl_printable_name (tree, int); extern int lhd_types_compatible_p (tree, tree); diff --git a/gcc/langhooks.c b/gcc/langhooks.c index e93204240ee..9f0a236e8d3 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -125,10 +125,10 @@ lhd_safe_from_p (rtx ARG_UNUSED (x), tree ARG_UNUSED (exp)) /* Called from staticp. */ -bool +tree lhd_staticp (tree ARG_UNUSED (exp)) { - return false; + return NULL; } /* Called from check_global_declarations. */ diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 586db387866..98532521e5e 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -299,7 +299,7 @@ struct lang_hooks bool (*mark_addressable) (tree); /* Hook called by staticp for language-specific tree codes. */ - bool (*staticp) (tree); + tree (*staticp) (tree); /* Replace the DECL_LANG_SPECIFIC data, which may be NULL, of the DECL_NODE with a newly GC-allocated copy. */ diff --git a/gcc/tree.c b/gcc/tree.c index d56be7c6eec..27efff1d49f 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1366,7 +1366,7 @@ array_type_nelts (tree type) /* Return true if arg is static -- a reference to an object in static storage. This is not the same as the C meaning of `static'. */ -bool +tree staticp (tree arg) { switch (TREE_CODE (arg)) @@ -1375,19 +1375,21 @@ staticp (tree arg) /* Nested functions aren't static, since taking their address involves a trampoline. */ return ((decl_function_context (arg) == 0 || DECL_NO_STATIC_CHAIN (arg)) - && ! DECL_NON_ADDR_CONST_P (arg)); + && ! DECL_NON_ADDR_CONST_P (arg) + ? arg : NULL); case VAR_DECL: return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg)) && ! DECL_THREAD_LOCAL (arg) - && ! DECL_NON_ADDR_CONST_P (arg)); + && ! DECL_NON_ADDR_CONST_P (arg) + ? arg : NULL); case CONSTRUCTOR: - return TREE_STATIC (arg); + return TREE_STATIC (arg) ? arg : NULL; case LABEL_DECL: case STRING_CST: - return true; + return arg; case COMPONENT_REF: /* If the thing being referenced is not a field, then it is @@ -1398,20 +1400,15 @@ staticp (tree arg) /* If we are referencing a bitfield, we can't evaluate an ADDR_EXPR at compile time and so it isn't a constant. */ if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1))) - return false; + return NULL; return staticp (TREE_OPERAND (arg, 0)); case BIT_FIELD_REF: - return false; + return NULL; -#if 0 - /* This case is technically correct, but results in setting - TREE_CONSTANT on ADDR_EXPRs that cannot be evaluated at - compile time. */ case INDIRECT_REF: - return TREE_CONSTANT (TREE_OPERAND (arg, 0)); -#endif + return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL; case ARRAY_REF: case ARRAY_RANGE_REF: @@ -1426,7 +1423,7 @@ staticp (tree arg) >= (unsigned int) LAST_AND_UNUSED_TREE_CODE) return lang_hooks.staticp (arg); else - return false; + return NULL; } } diff --git a/gcc/tree.h b/gcc/tree.h index 0c26e883d6c..bc0b1418e66 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3184,10 +3184,10 @@ extern int integer_pow2p (tree); extern int integer_nonzerop (tree); -/* staticp (tree x) is true if X is a reference to data allocated - at a fixed address in memory. */ +/* staticp (tree x) is nonzero if X is a reference to data allocated + at a fixed address in memory. Returns the outermost data. */ -extern bool staticp (tree); +extern tree staticp (tree); /* save_expr (EXP) returns an expression equivalent to EXP but it can be used multiple times within context CTX