diff options
-rw-r--r-- | gcc/ChangeLog | 29 | ||||
-rw-r--r-- | gcc/c-common.c | 9 | ||||
-rw-r--r-- | gcc/c-common.h | 1 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/tree.c | 8 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 | ||||
-rw-r--r-- | gcc/emit-rtl.c | 254 | ||||
-rw-r--r-- | gcc/gimple-low.c | 4 | ||||
-rw-r--r-- | gcc/jump.c | 7 | ||||
-rw-r--r-- | gcc/rtl.h | 10 | ||||
-rw-r--r-- | gcc/rtlanal.c | 5 | ||||
-rw-r--r-- | gcc/system.h | 11 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 22 | ||||
-rw-r--r-- | gcc/tree-flow.h | 2 | ||||
-rw-r--r-- | gcc/tree-iterator.c | 86 | ||||
-rw-r--r-- | gcc/tree.c | 37 | ||||
-rw-r--r-- | gcc/tree.h | 4 |
17 files changed, 204 insertions, 303 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a267bf64ba..4b0271c1c12 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,32 @@ +2007-09-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * c-common.c (const_strip_array_types): Delete. + * c-common.h (const_strip_array_types): Likewise. + * emit-rtl.c (const_next_insn, const_previous_insn, + const_next_nonnote_insn, const_prev_nonnote_insn, + const_next_real_insn, const_prev_real_insn, + const_next_active_insn, const_prev_active_insn, const_next_label, + const_prev_label): Delete. + * gimple-low.c (block_may_fallthru): Use expr_last. + * jump.c (reversed_comparison_code_parts): Use prev_nonnote_insn. + * rtl.h (const_previous_insn, const_next_insn, + const_prev_nonnote_insn, const_next_nonnote_insn, + const_prev_real_insn, const_next_real_insn, + const_prev_active_insn, const_next_active_insn, const_prev_label, + const_next_label): Delete. + * rtlanal.c (keep_with_call_p): Use next_nonnote_insn. + * system.h (CONST_CAST): Update comment. + * tree-cfg.c (tree_can_merge_blocks_p): Use last_stmt. + (const_first_stmt, const_last_stmt): Delete. + (tree_block_ends_with_condjump_p): Use last_stmt. + * tree-flow.h (const_first_stmt, const_last_stmt): Delete. + * tree-iterator.c (const_expr_first, const_expr_last, + const_expr_only): Delete. + * tree.c (const_lookup_attribute): Likewise. + (attribute_list_contained): Use lookup_attribute. + * tree.h (const_lookup_attribute, const_expr_first, + const_expr_last, const_expr_only): Delete. + 2007-09-01 Richard Guenther <rguenther@suse.de> * tree-ssa-alias.c (create_name_tags): Use TYPE_VOLATILE diff --git a/gcc/c-common.c b/gcc/c-common.c index 8e4ae22271b..147f5c17763 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -4164,15 +4164,6 @@ strip_array_types (tree type) return type; } -const_tree -const_strip_array_types (const_tree type) -{ - while (TREE_CODE (type) == ARRAY_TYPE) - type = TREE_TYPE (type); - - return type; -} - /* Recursively remove any '*' or '&' operator from TYPE. */ tree strip_pointer_operator (tree t) diff --git a/gcc/c-common.h b/gcc/c-common.h index 5a27eec5e6f..428cb21f5a6 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -734,7 +734,6 @@ extern void c_register_builtin_type (tree, const char*); extern bool c_promoting_integer_type_p (const_tree); extern int self_promoting_args_p (const_tree); extern tree strip_array_types (tree); -extern const_tree const_strip_array_types (const_tree); extern tree strip_pointer_operator (tree); extern tree strip_pointer_or_array_types (tree); extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 558aa067a43..7b1b70fa5e9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-09-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * tree.c (pod_type_p, zero_init_p): Use strip_array_types. + * typeck.c (cp_type_quals, cp_type_readonly, cp_has_mutable_p): + Likewise. + 2007-08-31 Douglas Gregor <doug.gregor@gmail.com> PR c++/32597 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4ee3f886d25..3424f7a2bd2 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2052,7 +2052,9 @@ is_dummy_object (const_tree ob) int pod_type_p (const_tree t) { - t = const_strip_array_types (t); + /* This CONST_CAST is okay because strip_array_types returns it's + argument unmodified and we assign it to a const_tree. */ + t = strip_array_types ((tree)CONST_CAST(t)); if (t == error_mark_node) return 1; @@ -2089,7 +2091,9 @@ class_tmpl_impl_spec_p (const_tree t) int zero_init_p (const_tree t) { - t = const_strip_array_types (t); + /* This CONST_CAST is okay because strip_array_types returns it's + argument unmodified and we assign it to a const_tree. */ + t = strip_array_types ((tree)CONST_CAST(t)); if (t == error_mark_node) return 1; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 87044be6b04..b57fbe5455f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6943,7 +6943,9 @@ comp_ptr_ttypes_const (tree to, tree from) int cp_type_quals (const_tree type) { - type = const_strip_array_types (type); + /* This CONST_CAST is okay because strip_array_types returns it's + argument unmodified and we assign it to a const_tree. */ + type = strip_array_types ((tree)CONST_CAST(type)); if (type == error_mark_node) return TYPE_UNQUALIFIED; return TYPE_QUALS (type); @@ -6955,7 +6957,9 @@ cp_type_quals (const_tree type) bool cp_type_readonly (const_tree type) { - type = const_strip_array_types (type); + /* This CONST_CAST is okay because strip_array_types returns it's + argument unmodified and we assign it to a const_tree. */ + type = strip_array_types ((tree)CONST_CAST(type)); return TYPE_READONLY (type); } @@ -6964,7 +6968,9 @@ cp_type_readonly (const_tree type) bool cp_has_mutable_p (const_tree type) { - type = const_strip_array_types (type); + /* This CONST_CAST is okay because strip_array_types returns it's + argument unmodified and we assign it to a const_tree. */ + type = strip_array_types ((tree)CONST_CAST(type)); return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type); } diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 6a4604d40e9..cf6b2f3ccd7 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -2865,169 +2865,103 @@ get_max_uid (void) /* Return the next insn. If it is a SEQUENCE, return the first insn of the sequence. */ -#define NEXT_INSN_BODY do { \ - if (insn) \ - { \ - insn = NEXT_INSN (insn); \ - if (insn && NONJUMP_INSN_P (insn) \ - && GET_CODE (PATTERN (insn)) == SEQUENCE) \ - insn = XVECEXP (PATTERN (insn), 0, 0); \ - } \ - return insn; \ -} while (0) - rtx next_insn (rtx insn) { - NEXT_INSN_BODY; -} + if (insn) + { + insn = NEXT_INSN (insn); + if (insn && NONJUMP_INSN_P (insn) + && GET_CODE (PATTERN (insn)) == SEQUENCE) + insn = XVECEXP (PATTERN (insn), 0, 0); + } -const_rtx -const_next_insn (const_rtx insn) -{ - NEXT_INSN_BODY; + return insn; } -#undef NEXT_INSN_BODY - /* Return the previous insn. If it is a SEQUENCE, return the last insn of the sequence. */ -#define PREVIOUS_INSN_BODY do { \ - if (insn) \ - { \ - insn = PREV_INSN (insn); \ - if (insn && NONJUMP_INSN_P (insn) \ - && GET_CODE (PATTERN (insn)) == SEQUENCE) \ - insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1); \ - } \ - return insn; \ -} while (0) - rtx previous_insn (rtx insn) { - PREVIOUS_INSN_BODY; -} + if (insn) + { + insn = PREV_INSN (insn); + if (insn && NONJUMP_INSN_P (insn) + && GET_CODE (PATTERN (insn)) == SEQUENCE) + insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1); + } -const_rtx -const_previous_insn (const_rtx insn) -{ - PREVIOUS_INSN_BODY; + return insn; } -#undef PREVIOUS_INSN_BODY - /* Return the next insn after INSN that is not a NOTE. This routine does not look inside SEQUENCEs. */ -#define NEXT_NONNOTE_INSN_BODY do { \ - while (insn) \ - { \ - insn = NEXT_INSN (insn); \ - if (insn == 0 || !NOTE_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx next_nonnote_insn (rtx insn) { - NEXT_NONNOTE_INSN_BODY; -} + while (insn) + { + insn = NEXT_INSN (insn); + if (insn == 0 || !NOTE_P (insn)) + break; + } -const_rtx -const_next_nonnote_insn (const_rtx insn) -{ - NEXT_NONNOTE_INSN_BODY; + return insn; } -#undef NEXT_NONNOTE_INSN_BODY - /* Return the previous insn before INSN that is not a NOTE. This routine does not look inside SEQUENCEs. */ -#define PREV_NONNOTE_INSN_BODY do { \ - while (insn) \ - { \ - insn = PREV_INSN (insn); \ - if (insn == 0 || !NOTE_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx prev_nonnote_insn (rtx insn) { - PREV_NONNOTE_INSN_BODY; -} + while (insn) + { + insn = PREV_INSN (insn); + if (insn == 0 || !NOTE_P (insn)) + break; + } -const_rtx -const_prev_nonnote_insn (const_rtx insn) -{ - PREV_NONNOTE_INSN_BODY; + return insn; } -#undef PREV_NONNOTE_INSN_BODY - /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN; or 0, if there is none. This routine does not look inside SEQUENCEs. */ -#define NEXT_REAL_INSN_BODY do { \ - while (insn) \ - { \ - insn = NEXT_INSN (insn); \ - if (insn == 0 || INSN_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx next_real_insn (rtx insn) { - NEXT_REAL_INSN_BODY; -} + while (insn) + { + insn = NEXT_INSN (insn); + if (insn == 0 || INSN_P (insn)) + break; + } -const_rtx -const_next_real_insn (const_rtx insn) -{ - NEXT_REAL_INSN_BODY; + return insn; } -#undef NEXT_REAL_INSN_BODY - /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN; or 0, if there is none. This routine does not look inside SEQUENCEs. */ -#define PREV_REAL_INSN_BODY do { \ - while (insn) \ - { \ - insn = PREV_INSN (insn); \ - if (insn == 0 || INSN_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx prev_real_insn (rtx insn) { - PREV_REAL_INSN_BODY; -} + while (insn) + { + insn = PREV_INSN (insn); + if (insn == 0 || INSN_P (insn)) + break; + } -const_rtx -const_prev_real_insn (const_rtx insn) -{ - PREV_REAL_INSN_BODY; + return insn; } -#undef PREV_REAL_INSN_BODY - /* Return the last CALL_INSN in the current list, or 0 if there is none. This routine does not look inside SEQUENCEs. */ @@ -3058,110 +2992,66 @@ active_insn_p (const_rtx insn) && GET_CODE (PATTERN (insn)) != CLOBBER)))); } -#define NEXT_ACTIVE_INSN_BODY do { \ - while (insn) \ - { \ - insn = NEXT_INSN (insn); \ - if (insn == 0 || active_insn_p (insn)) \ - break; \ - } \ - return insn;\ -} while (0) - rtx next_active_insn (rtx insn) { - NEXT_ACTIVE_INSN_BODY; -} + while (insn) + { + insn = NEXT_INSN (insn); + if (insn == 0 || active_insn_p (insn)) + break; + } -const_rtx -const_next_active_insn (const_rtx insn) -{ - NEXT_ACTIVE_INSN_BODY; + return insn; } -#undef NEXT_ACTIVE_INSN_BODY - /* Find the last insn before INSN that really does something. This routine does not look inside SEQUENCEs. Until reload has completed, this is the same as prev_real_insn. */ -#define PREV_ACTIVE_INSN_BODY do { \ - while (insn) \ - { \ - insn = PREV_INSN (insn);\ - if (insn == 0 || active_insn_p (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx prev_active_insn (rtx insn) { - PREV_ACTIVE_INSN_BODY; -} + while (insn) + { + insn = PREV_INSN (insn); + if (insn == 0 || active_insn_p (insn)) + break; + } -const_rtx -const_prev_active_insn (const_rtx insn) -{ - PREV_ACTIVE_INSN_BODY; + return insn; } -#undef PREV_ACTIVE_INSN_BODY - /* Return the next CODE_LABEL after the insn INSN, or 0 if there is none. */ -#define NEXT_LABEL_BODY do { \ - while (insn) \ - { \ - insn = NEXT_INSN (insn); \ - if (insn == 0 || LABEL_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx next_label (rtx insn) { - NEXT_LABEL_BODY; -} + while (insn) + { + insn = NEXT_INSN (insn); + if (insn == 0 || LABEL_P (insn)) + break; + } -const_rtx -const_next_label (const_rtx insn) -{ - NEXT_LABEL_BODY; + return insn; } -#undef NEXT_LABEL_BODY - /* Return the last CODE_LABEL before the insn INSN, or 0 if there is none. */ -#define PREV_LABEL_BODY do { \ - while (insn) \ - { \ - insn = PREV_INSN (insn); \ - if (insn == 0 || LABEL_P (insn)) \ - break; \ - } \ - return insn; \ -} while (0) - rtx prev_label (rtx insn) { - PREV_LABEL_BODY; -} + while (insn) + { + insn = PREV_INSN (insn); + if (insn == 0 || LABEL_P (insn)) + break; + } -const_rtx -const_prev_label (const_rtx insn) -{ - PREV_LABEL_BODY; + return insn; } -#undef PREV_LABEL_BODY - /* Return the last label to mark the same position as LABEL. Return null if LABEL itself is null. */ diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index ba539ac7e50..74f9ffb9f72 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -396,7 +396,9 @@ try_catch_may_fallthru (const_tree stmt) bool block_may_fallthru (const_tree block) { - const_tree stmt = const_expr_last (block); + /* This CONST_CAST is okay because expr_last returns it's argument + unmodified and we assign it to a const_tree. */ + const_tree stmt = expr_last ((tree)CONST_CAST(block)); switch (stmt ? TREE_CODE (stmt) : ERROR_MARK) { diff --git a/gcc/jump.c b/gcc/jump.c index 959b79af54b..7a040d11aa5 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -299,9 +299,12 @@ reversed_comparison_code_parts (enum rtx_code code, const_rtx arg0, if (! insn) return UNKNOWN; - for (prev = const_prev_nonnote_insn (insn); + /* These CONST_CAST's are okay because prev_nonnote_insn just + returns it's argument and we assign it to a const_rtx + variable. */ + for (prev = prev_nonnote_insn ((rtx)(CONST_CAST(insn))); prev != 0 && !LABEL_P (prev); - prev = const_prev_nonnote_insn (prev)) + prev = prev_nonnote_insn ((rtx)(CONST_CAST(prev)))) { const_rtx set = set_of (arg0, prev); if (set && GET_CODE (set) == SET diff --git a/gcc/rtl.h b/gcc/rtl.h index 5484df11a3c..0a114c3dbbd 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1593,26 +1593,16 @@ extern rtx make_jump_insn_raw (rtx); extern void add_function_usage_to (rtx, rtx); extern rtx last_call_insn (void); extern rtx previous_insn (rtx); -extern const_rtx const_previous_insn (const_rtx); extern rtx next_insn (rtx); -extern const_rtx const_next_insn (const_rtx); extern rtx prev_nonnote_insn (rtx); -extern const_rtx const_prev_nonnote_insn (const_rtx); extern rtx next_nonnote_insn (rtx); -extern const_rtx const_next_nonnote_insn (const_rtx); extern rtx prev_real_insn (rtx); -extern const_rtx const_prev_real_insn (const_rtx); extern rtx next_real_insn (rtx); -extern const_rtx const_next_real_insn (const_rtx); extern rtx prev_active_insn (rtx); -extern const_rtx const_prev_active_insn (const_rtx); extern rtx next_active_insn (rtx); -extern const_rtx const_next_active_insn (const_rtx); extern int active_insn_p (const_rtx); extern rtx prev_label (rtx); -extern const_rtx const_prev_label (const_rtx); extern rtx next_label (rtx); -extern const_rtx const_next_label (const_rtx); extern rtx skip_consecutive_labels (rtx); extern rtx next_cc0_user (rtx); extern rtx prev_cc0_setter (rtx); diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 4a4a62904b5..1d90a1207fb 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -3392,7 +3392,10 @@ keep_with_call_p (const_rtx insn) if we can break or not. */ if (SET_DEST (set) == stack_pointer_rtx) { - const_rtx i2 = const_next_nonnote_insn (insn); + /* This CONST_CAST is okay because next_nonnote_insn just + returns it's argument and we assign it to a const_rtx + variable. */ + const_rtx i2 = next_nonnote_insn ((rtx)CONST_CAST(insn)); if (i2 && keep_with_call_p (i2)) return true; } diff --git a/gcc/system.h b/gcc/system.h index 0225d8b8302..84ddf4953ab 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -772,8 +772,15 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; the C standard definitions or prototypes force you to. E.g. if you need to free a const object, or if you pass a const string to execv, et al. Another valid use would be in an allocation function - that creates const objects that need to be initialized. Most other - cases should be viewed with extreme caution. */ + that creates const objects that need to be initialized. In some + cases we have non-const functions that return the argument + (e.g. next_nonnote_insn). Rather than create const shadow + functions, we can cast away const-ness in calling these interfaces + if we're careful to verify that the called function does indeed not + modify its argument and the return value is only used in a const + context. (This can be somewhat dangerous as these assumptions can + change after the fact). Beyond these uses, most other cases of + using this macro should be viewed with extreme caution. */ #if defined(__GNUC__) && GCC_VERSION != 4000 /* GCC 4.0.x has a bug where it may ICE on this expression. */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e70b440dfc2..947b8deaa5f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1158,7 +1158,9 @@ tree_can_merge_blocks_p (const_basic_block a, const_basic_block b) /* If A ends by a statement causing exceptions or something similar, we cannot merge the blocks. */ - stmt = const_last_stmt (a); + /* This CONST_CAST is okay because last_stmt doesn't modify its + argument and the return value is assign to a const_tree. */ + stmt = last_stmt ((basic_block)CONST_CAST(a)); if (stmt && stmt_ends_bb_p (stmt)) return false; @@ -2592,13 +2594,6 @@ first_stmt (basic_block bb) return !bsi_end_p (i) ? bsi_stmt (i) : NULL_TREE; } -const_tree -const_first_stmt (const_basic_block bb) -{ - const_block_stmt_iterator i = cbsi_start (bb); - return !cbsi_end_p (i) ? cbsi_stmt (i) : NULL_TREE; -} - /* Return the last statement in basic block BB. */ tree @@ -2608,13 +2603,6 @@ last_stmt (basic_block bb) return !bsi_end_p (b) ? bsi_stmt (b) : NULL_TREE; } -const_tree -const_last_stmt (const_basic_block bb) -{ - const_block_stmt_iterator b = cbsi_last (bb); - return !cbsi_end_p (b) ? cbsi_stmt (b) : NULL_TREE; -} - /* Return the last statement of an otherwise empty block. Return NULL if the block is totally empty, or if it contains more than one statement. */ @@ -5932,7 +5920,9 @@ tree_block_ends_with_call_p (const_basic_block bb) static bool tree_block_ends_with_condjump_p (const_basic_block bb) { - const_tree stmt = const_last_stmt (bb); + /* This CONST_CAST is okay because last_stmt doesn't modify its + argument and the return value is not modified. */ + const_tree stmt = last_stmt ((basic_block)CONST_CAST(bb)); return (stmt && TREE_CODE (stmt) == COND_EXPR); } diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 044a520b710..e2eb8822317 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -740,9 +740,7 @@ extern void print_loop_ir (FILE *); extern void cleanup_dead_labels (void); extern void group_case_labels (void); extern tree first_stmt (basic_block); -extern const_tree const_first_stmt (const_basic_block); extern tree last_stmt (basic_block); -extern const_tree const_last_stmt (const_basic_block); extern tree last_and_only_stmt (basic_block); extern edge find_taken_edge (basic_block, tree); extern basic_block label_to_block_fn (struct function *, tree); diff --git a/gcc/tree-iterator.c b/gcc/tree-iterator.c index 1e7a682d391..a49744cf6c0 100644 --- a/gcc/tree-iterator.c +++ b/gcc/tree-iterator.c @@ -299,29 +299,22 @@ tsi_split_statement_list_before (tree_stmt_iterator *i) /* Return the first expression in a sequence of COMPOUND_EXPRs, or in a STATEMENT_LIST. */ -#define EXPR_FIRST_BODY do { \ - if (expr == NULL_TREE) \ - return expr; \ - if (TREE_CODE (expr) == STATEMENT_LIST) \ - { \ - struct tree_statement_list_node *n = STATEMENT_LIST_HEAD (expr); \ - return n ? n->stmt : NULL_TREE; \ - } \ - while (TREE_CODE (expr) == COMPOUND_EXPR) \ - expr = TREE_OPERAND (expr, 0); \ - return expr; \ -} while (0) - tree expr_first (tree expr) { - EXPR_FIRST_BODY; -} + if (expr == NULL_TREE) + return expr; -const_tree -const_expr_first (const_tree expr) -{ - EXPR_FIRST_BODY; + if (TREE_CODE (expr) == STATEMENT_LIST) + { + struct tree_statement_list_node *n = STATEMENT_LIST_HEAD (expr); + return n ? n->stmt : NULL_TREE; + } + + while (TREE_CODE (expr) == COMPOUND_EXPR) + expr = TREE_OPERAND (expr, 0); + + return expr; } /* Return the last expression in a sequence of COMPOUND_EXPRs, @@ -343,45 +336,44 @@ const_expr_first (const_tree expr) tree expr_last (tree expr) { - EXPR_LAST_BODY; -} + if (expr == NULL_TREE) + return expr; -const_tree -const_expr_last (const_tree expr) -{ - EXPR_LAST_BODY; + if (TREE_CODE (expr) == STATEMENT_LIST) + { + struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); + return n ? n->stmt : NULL_TREE; + } + + while (TREE_CODE (expr) == COMPOUND_EXPR) + expr = TREE_OPERAND (expr, 1); + + return expr; } /* If EXPR is a single statement return it. If EXPR is a STATEMENT_LIST containing exactly one statement S, return S. Otherwise, return NULL. */ -#define EXPR_ONLY_BODY do { \ - if (expr == NULL_TREE) \ - return NULL_TREE; \ - if (TREE_CODE (expr) == STATEMENT_LIST) \ - { \ - struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); \ - if (n && STATEMENT_LIST_HEAD (expr) == n) \ - return n->stmt; \ - else \ - return NULL_TREE; \ - } \ - if (TREE_CODE (expr) == COMPOUND_EXPR) \ - return NULL_TREE; \ - return expr; \ -} while (0) - tree expr_only (tree expr) { - EXPR_ONLY_BODY; -} + if (expr == NULL_TREE) + return NULL_TREE; -const_tree -const_expr_only (const_tree expr) -{ - EXPR_ONLY_BODY; + if (TREE_CODE (expr) == STATEMENT_LIST) + { + struct tree_statement_list_node *n = STATEMENT_LIST_TAIL (expr); + if (n && STATEMENT_LIST_HEAD (expr) == n) + return n->stmt; + else + return NULL_TREE; + } + + if (TREE_CODE (expr) == COMPOUND_EXPR) + return NULL_TREE; + + return expr; } #include "gt-tree-iterator.h" diff --git a/gcc/tree.c b/gcc/tree.c index c9587aafb26..d04c1f0222b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3809,28 +3809,19 @@ is_attribute_p (const char *attr, const_tree ident) returns the first occurrence; the TREE_CHAIN of the return value should be passed back in if further occurrences are wanted. */ -#define LOOKUP_ATTRIBUTE_BODY(TYPE) do { \ - TYPE l; \ - size_t attr_len = strlen (attr_name); \ - for (l = list; l; l = TREE_CHAIN (l)) \ - { \ - gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE); \ - if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE (l))) \ - return l; \ - } \ - return NULL_TREE; \ -} while (0) - tree lookup_attribute (const char *attr_name, tree list) { - LOOKUP_ATTRIBUTE_BODY(tree); -} + tree l; + size_t attr_len = strlen (attr_name); -const_tree -const_lookup_attribute (const char *attr_name, const_tree list) -{ - LOOKUP_ATTRIBUTE_BODY(const_tree); + for (l = list; l; l = TREE_CHAIN (l)) + { + gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE); + if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE (l))) + return l; + } + return NULL_TREE; } /* Remove any instances of attribute ATTR_NAME in LIST and return the @@ -4800,10 +4791,14 @@ attribute_list_contained (const_tree l1, const_tree l2) for (; t2 != 0; t2 = TREE_CHAIN (t2)) { const_tree attr; - for (attr = const_lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), l1); + /* This CONST_CAST is okay because lookup_attribute does not + modify its argument and the return value is assigned to a + const_tree. */ + for (attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), + (tree)CONST_CAST(l1)); attr != NULL_TREE; - attr = const_lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), - TREE_CHAIN (attr))) + attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), + TREE_CHAIN (attr))) { if (TREE_VALUE (t2) != NULL && TREE_CODE (TREE_VALUE (t2)) == TREE_LIST diff --git a/gcc/tree.h b/gcc/tree.h index 4985fa903d6..23916cfebb8 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4156,7 +4156,6 @@ extern int is_attribute_p (const char *, const_tree); of the attribute or NULL_TREE if not found. */ extern tree lookup_attribute (const char *, tree); -extern const_tree const_lookup_attribute (const char *, const_tree); /* Remove any instances of attribute ATTR_NAME in LIST and return the modified list. */ @@ -4303,11 +4302,8 @@ extern tree non_lvalue (tree); extern tree convert (tree, tree); extern unsigned int expr_align (const_tree); extern tree expr_first (tree); -extern const_tree const_expr_first (const_tree); extern tree expr_last (tree); -extern const_tree const_expr_last (const_tree); extern tree expr_only (tree); -extern const_tree const_expr_only (const_tree); extern tree size_in_bytes (const_tree); extern HOST_WIDE_INT int_size_in_bytes (const_tree); extern HOST_WIDE_INT max_int_size_in_bytes (const_tree); |