From 7c34ced1a25f62ed12b1bf1158167fe157b60ae7 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 19 Jun 2004 12:34:23 -0700 Subject: [PATCH] c-common.c, c-common.h (lang_gimplify_stmt): Remove. * c-common.c, c-common.h (lang_gimplify_stmt): Remove. * c-gimplify.c: Remove unnecessary prototypes. (c_gimplify_stmt): Merge into ... (c_gimplify_expr): ... here. Don't play with prep_stmt. * c-semantics.c (prep_stmt): Remove. * gimplify.c (annotate_one_with_locus): Break out from ... (annotate_all_with_locus): ... here. (gimplify_expr): Add locus to expressions even if pre/post queues are not present. cp/ * cp-gimplify.c: Remove unnecessary prototypes. (cp_gimplify_stmt): Merge into ... (cp_gimplify_expr): ... here. Move to end of file. Handle stmts_are_full_exprs_p frobbing. * cp-tree.h (cp_gimplify_stmt): Remove. * pt.c (tsubst_expr): Merge prep_stmt and unify. * tree.c (init_tree): Don't set lang_gimplify_stmt. From-SVN: r83397 --- gcc/ChangeLog | 12 ++++ gcc/c-common.c | 5 -- gcc/c-common.h | 7 +- gcc/c-gimplify.c | 170 ++++++++++------------------------------------- gcc/c-semantics.c | 11 ---- gcc/cp/ChangeLog | 10 +++ gcc/cp/cp-gimplify.c | 181 +++++++++++++++++++++++++++------------------------ gcc/cp/cp-tree.h | 1 - gcc/cp/pt.c | 155 +++++++++++++++++-------------------------- gcc/cp/tree.c | 1 - gcc/gimplify.c | 18 +++-- 11 files changed, 225 insertions(+), 346 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 242be1c..03764bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2004-04-19 Richard Henderson + + * c-common.c, c-common.h (lang_gimplify_stmt): Remove. + * c-gimplify.c: Remove unnecessary prototypes. + (c_gimplify_stmt): Merge into ... + (c_gimplify_expr): ... here. Don't play with prep_stmt. + * c-semantics.c (prep_stmt): Remove. + * gimplify.c (annotate_one_with_locus): Break out from ... + (annotate_all_with_locus): ... here. + (gimplify_expr): Add locus to expressions even if pre/post queues + are not present. + 2004-06-19 Richard Henderson PR target/15941 diff --git a/gcc/c-common.c b/gcc/c-common.c index d25dde3..a982852 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -690,11 +690,6 @@ tree (*make_fname_decl) (tree, int); returns 1 for language-specific statement codes. */ int (*lang_statement_code_p) (enum tree_code); -/* If non-NULL, the address of a language-specific function that does any - language-specific gimplification for _STMT nodes and returns 1 iff - handled. */ -int (*lang_gimplify_stmt) (tree *); - /* If non-NULL, the address of a language-specific function that takes any action required right before expand_function_end is called. */ void (*lang_expand_function_end) (void); diff --git a/gcc/c-common.h b/gcc/c-common.h index 337eb6d..b1c49b1 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -280,7 +280,6 @@ struct c_language_function GTY(()) { /* Language-specific hooks. */ -extern int (*lang_gimplify_stmt) (tree *); extern void (*lang_expand_function_end) (void); /* Callback that determines if it's ok for a function to have no @@ -299,7 +298,6 @@ extern void add_decl_stmt (tree); extern void push_cleanup (tree, tree, bool); extern tree walk_stmt_tree (tree *, walk_tree_fn, void *); -extern void prep_stmt (tree); extern int c_expand_decl (tree); extern int field_decl_cmp (const void *, const void *); @@ -1113,14 +1111,13 @@ extern void dump_time_statistics (void); extern bool c_dump_tree (void *, tree); -extern int c_gimplify_expr (tree *, tree *, tree *); extern tree c_walk_subtrees (tree*, int*, walk_tree_fn, void*, void*); extern void c_warn_unused_result (tree *); -/* In c-simplify.c */ +/* In c-gimplify.c */ extern void c_genericize (tree); -extern int c_gimplify_stmt (tree *); +extern int c_gimplify_expr (tree *, tree *, tree *); extern tree c_build_bind_expr (tree, tree); extern void pch_init (void); diff --git a/gcc/c-gimplify.c b/gcc/c-gimplify.c index 7334621..1f8ce64 100644 --- a/gcc/c-gimplify.c +++ b/gcc/c-gimplify.c @@ -72,25 +72,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA /* Local declarations. */ -static enum gimplify_status gimplify_expr_stmt (tree *); -static enum gimplify_status gimplify_decl_stmt (tree *); -static enum gimplify_status gimplify_for_stmt (tree *, tree *); -static enum gimplify_status gimplify_while_stmt (tree *); -static enum gimplify_status gimplify_do_stmt (tree *); -static enum gimplify_status gimplify_if_stmt (tree *); -static enum gimplify_status gimplify_switch_stmt (tree *); -static enum gimplify_status gimplify_return_stmt (tree *); -static enum gimplify_status gimplify_compound_literal_expr (tree *); static void gimplify_cleanup_stmts (tree); -static tree gimplify_c_loop (tree, tree, tree, bool); -static void push_context (void); -static void pop_context (void); -static void add_block_to_enclosing (tree); enum bc_t { bc_break = 0, bc_continue = 1 }; -static tree begin_bc_block (enum bc_t); -static tree finish_bc_block (tree, tree); -static tree build_bc_goto (enum bc_t); static struct c_gimplify_ctx { @@ -192,122 +176,6 @@ gimplify_cleanup_stmts (tree fndecl) walk_tree (&DECL_SAVED_TREE (fndecl), gimplify_cleanup_stmt, NULL, NULL); } -/* Entry point for the tree lowering pass. Recursively scan - *STMT_P and convert it to a GIMPLE tree. */ - -int -c_gimplify_stmt (tree *stmt_p) -{ - tree stmt = *stmt_p; - tree pre, post; - int saved_stmts_are_full_exprs_p; - location_t stmt_locus; - enum gimplify_status ret; - - /* PRE and POST are tree chains that contain the side-effects of the - gimplified tree. For instance, given the expression tree: - - c = ++a * 3 + b++; - - After gimplification, the tree will be re-written as: - - a = a + 1; - t1 = a * 3; <-- PRE - c = t1 + b; - b = b + 1; <-- POST */ - - /* Set up context appropriately for handling this statement. */ - saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p (); - prep_stmt (stmt); - stmt_locus = input_location; - - pre = NULL_TREE; - post = NULL_TREE; - - switch (TREE_CODE (stmt)) - { - case FOR_STMT: - ret = gimplify_for_stmt (&stmt, &pre); - break; - - case WHILE_STMT: - ret = gimplify_while_stmt (&stmt); - break; - - case DO_STMT: - ret = gimplify_do_stmt (&stmt); - break; - - case IF_STMT: - ret = gimplify_if_stmt (&stmt); - break; - - case SWITCH_STMT: - ret = gimplify_switch_stmt (&stmt); - break; - - case EXPR_STMT: - ret = gimplify_expr_stmt (&stmt); - break; - - case RETURN_STMT: - ret = gimplify_return_stmt (&stmt); - break; - - case DECL_STMT: - ret = gimplify_decl_stmt (&stmt); - break; - - case CONTINUE_STMT: - stmt = build_bc_goto (bc_continue); - ret = GS_OK; - break; - - case BREAK_STMT: - stmt = build_bc_goto (bc_break); - ret = GS_OK; - break; - - default: - if (lang_gimplify_stmt && (*lang_gimplify_stmt) (&stmt)) - { - ret = GS_OK; - break; - } - - fprintf (stderr, "unhandled statement node in c_gimplify_stmt:\n"); - debug_tree (stmt); - abort (); - break; - } - - switch (ret) - { - case GS_ERROR: - goto cont; - case GS_OK: - gimplify_stmt (&stmt); - break; - case GS_ALL_DONE: - break; - default: - abort (); - } - - /* PRE and POST now contain a list of statements for all the - side-effects in STMT. */ - - append_to_statement_list (stmt, &pre); - append_to_statement_list (post, &pre); - annotate_all_with_locus (&pre, stmt_locus); - cont: - /* Restore saved state. */ - current_stmt_tree ()->stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p; - *stmt_p = pre; - - return GS_ALL_DONE; -} - static void add_block_to_enclosing (tree block) { @@ -784,19 +652,47 @@ gimplify_compound_literal_expr (tree *expr_p) /* Do C-specific gimplification. Args are as for gimplify_expr. */ int -c_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED, - tree *post_p ATTRIBUTE_UNUSED) +c_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED) { enum tree_code code = TREE_CODE (*expr_p); - if (STATEMENT_CODE_P (code)) - return c_gimplify_stmt (expr_p); - switch (code) { case COMPOUND_LITERAL_EXPR: return gimplify_compound_literal_expr (expr_p); + case FOR_STMT: + return gimplify_for_stmt (expr_p, pre_p); + + case WHILE_STMT: + return gimplify_while_stmt (expr_p); + + case DO_STMT: + return gimplify_do_stmt (expr_p); + + case IF_STMT: + return gimplify_if_stmt (expr_p); + + case SWITCH_STMT: + return gimplify_switch_stmt (expr_p); + + case EXPR_STMT: + return gimplify_expr_stmt (expr_p); + + case RETURN_STMT: + return gimplify_return_stmt (expr_p); + + case DECL_STMT: + return gimplify_decl_stmt (expr_p); + + case CONTINUE_STMT: + *expr_p = build_bc_goto (bc_continue); + return GS_ALL_DONE; + + case BREAK_STMT: + *expr_p = build_bc_goto (bc_break); + return GS_ALL_DONE; + default: return GS_UNHANDLED; } diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c index 681887f..8a98e07 100644 --- a/gcc/c-semantics.c +++ b/gcc/c-semantics.c @@ -304,14 +304,3 @@ build_case_label (tree low_value, tree high_value, tree label_decl) { return build_stmt (CASE_LABEL_EXPR, low_value, high_value, label_decl); } - -/* We're about to expand T, a statement. Set up appropriate context - for the substitution. */ - -void -prep_stmt (tree t) -{ - if (EXPR_LOCUS (t)) - input_location = *EXPR_LOCUS (t); - current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t); -} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d830e20..73ead05 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2004-06-19 Richard Henderson + + * cp-gimplify.c: Remove unnecessary prototypes. + (cp_gimplify_stmt): Merge into ... + (cp_gimplify_expr): ... here. Move to end of file. Handle + stmts_are_full_exprs_p frobbing. + * cp-tree.h (cp_gimplify_stmt): Remove. + * pt.c (tsubst_expr): Merge prep_stmt and unify. + * tree.c (init_tree): Don't set lang_gimplify_stmt. + 2004-06-18 Richard Henderson PR c++/16034 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 2884d8b..9901643 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -30,43 +30,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "toplev.h" #include "tree-gimple.h" -static void genericize_try_block (tree *); -static void genericize_catch_block (tree *); -static void genericize_eh_spec_block (tree *); -static void gimplify_must_not_throw_expr (tree *, tree *); -static void cp_gimplify_init_expr (tree *, tree *, tree *); - -/* Genericize a C++ _STMT. Called from c_gimplify_stmt. */ - -int -cp_gimplify_stmt (tree *stmt_p) -{ - tree stmt = *stmt_p; - switch (TREE_CODE (stmt)) - { - case TRY_BLOCK: - genericize_try_block (stmt_p); - return 1; - - case HANDLER: - genericize_catch_block (stmt_p); - return 1; - - case EH_SPEC_BLOCK: - genericize_eh_spec_block (stmt_p); - return 1; - - case USING_STMT: - /* Just ignore for now. Eventually we will want to pass this on to - the debugger. */ - *stmt_p = build_empty_stmt (); - return 1; - - default: - break; - } - return 0; -} /* Genericize a TRY_BLOCK. */ @@ -116,54 +79,6 @@ genericize_eh_spec_block (tree *stmt_p) *stmt_p = gimple_build_eh_filter (body, allowed, failure); } -/* Do C++-specific gimplification. Args are as for gimplify_expr. */ - -int -cp_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p) -{ - switch (TREE_CODE (*expr_p)) - { - case PTRMEM_CST: - *expr_p = cplus_expand_constant (*expr_p); - return GS_OK; - - case AGGR_INIT_EXPR: - simplify_aggr_init_expr (expr_p); - return GS_OK; - - case THROW_EXPR: - /* FIXME communicate throw type to backend, probably by moving - THROW_EXPR into ../tree.def. */ - *expr_p = TREE_OPERAND (*expr_p, 0); - return GS_OK; - - case MUST_NOT_THROW_EXPR: - gimplify_must_not_throw_expr (expr_p, pre_p); - return GS_OK; - - case INIT_EXPR: - case MODIFY_EXPR: - cp_gimplify_init_expr (expr_p, pre_p, post_p); - return GS_OK; - - case EMPTY_CLASS_EXPR: - { - /* Yes, an INTEGER_CST with RECORD_TYPE. */ - tree i = build_int_2 (0, 0); - TREE_TYPE (i) = TREE_TYPE (*expr_p); - *expr_p = i; - } - return GS_OK; - - case BASELINK: - *expr_p = BASELINK_FUNCTIONS (*expr_p); - return GS_OK; - - default: - return c_gimplify_expr (expr_p, pre_p, post_p); - } -} - /* Gimplify initialization from an AGGR_INIT_EXPR. */ static void @@ -225,3 +140,99 @@ gimplify_must_not_throw_expr (tree *expr_p, tree *pre_p) else *expr_p = stmt; } + +/* Do C++-specific gimplification. Args are as for gimplify_expr. */ + +int +cp_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p) +{ + int saved_stmts_are_full_exprs_p = 0; + enum tree_code code = TREE_CODE (*expr_p); + enum gimplify_status ret; + + if (STATEMENT_CODE_P (code)) + { + saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p (); + current_stmt_tree ()->stmts_are_full_exprs_p + = STMT_IS_FULL_EXPR_P (*expr_p); + } + + switch (code) + { + case PTRMEM_CST: + *expr_p = cplus_expand_constant (*expr_p); + ret = GS_OK; + break; + + case AGGR_INIT_EXPR: + simplify_aggr_init_expr (expr_p); + ret = GS_OK; + break; + + case THROW_EXPR: + /* FIXME communicate throw type to backend, probably by moving + THROW_EXPR into ../tree.def. */ + *expr_p = TREE_OPERAND (*expr_p, 0); + ret = GS_OK; + break; + + case MUST_NOT_THROW_EXPR: + gimplify_must_not_throw_expr (expr_p, pre_p); + ret = GS_OK; + break; + + case INIT_EXPR: + case MODIFY_EXPR: + cp_gimplify_init_expr (expr_p, pre_p, post_p); + ret = GS_OK; + break; + + case EMPTY_CLASS_EXPR: + { + /* Yes, an INTEGER_CST with RECORD_TYPE. */ + tree i = build_int_2 (0, 0); + TREE_TYPE (i) = TREE_TYPE (*expr_p); + *expr_p = i; + } + ret = GS_OK; + break; + + case BASELINK: + *expr_p = BASELINK_FUNCTIONS (*expr_p); + ret = GS_OK; + break; + + case TRY_BLOCK: + genericize_try_block (expr_p); + ret = GS_OK; + break; + + case HANDLER: + genericize_catch_block (expr_p); + ret = GS_OK; + break; + + case EH_SPEC_BLOCK: + genericize_eh_spec_block (expr_p); + ret = GS_OK; + break; + + case USING_STMT: + /* Just ignore for now. Eventually we will want to pass this on to + the debugger. */ + *expr_p = build_empty_stmt (); + ret = GS_ALL_DONE; + break; + + default: + ret = c_gimplify_expr (expr_p, pre_p, post_p); + break; + } + + /* Restore saved state. */ + if (STATEMENT_CODE_P (code)) + current_stmt_tree ()->stmts_are_full_exprs_p + = saved_stmts_are_full_exprs_p; + + return ret; +} diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index cb2a143..7a0c41d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4305,7 +4305,6 @@ extern bool cp_dump_tree (void *, tree); /* in cp-simplify.c */ extern int cp_gimplify_expr (tree *, tree *, tree *); -extern int cp_gimplify_stmt (tree *); /* -- end of C++ */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d724a13..a73ef18 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7747,6 +7747,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (t == NULL_TREE || t == error_mark_node) return t; + if (EXPR_LOCUS (t)) + input_location = *EXPR_LOCUS (t); + if (STATEMENT_CODE_P (TREE_CODE (t))) + current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t); + switch (TREE_CODE (t)) { case STATEMENT_LIST: @@ -7758,13 +7763,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) } case CTOR_INITIALIZER: - prep_stmt (t); finish_mem_initializers (tsubst_initializer_list (TREE_OPERAND (t, 0), args)); break; case RETURN_STMT: - prep_stmt (t); finish_return_stmt (tsubst_expr (RETURN_STMT_EXPR (t), args, complain, in_decl)); break; @@ -7783,21 +7786,14 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) } case EXPR_STMT: - { - tree r; - - prep_stmt (t); - - r = tsubst_expr (EXPR_STMT_EXPR (t), args, complain, in_decl); - if (EXPR_STMT_STMT_EXPR_RESULT (t)) - finish_stmt_expr_expr (r, cur_stmt_expr); - else - finish_expr_stmt (r); - break; - } + tmp = tsubst_expr (EXPR_STMT_EXPR (t), args, complain, in_decl); + if (EXPR_STMT_STMT_EXPR_RESULT (t)) + finish_stmt_expr_expr (tmp, cur_stmt_expr); + else + finish_expr_stmt (tmp); + break; case USING_STMT: - prep_stmt (t); do_using_directive (tsubst_expr (USING_STMT_NAMESPACE (t), args, complain, in_decl)); break; @@ -7807,7 +7803,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) tree decl; tree init; - prep_stmt (t); decl = DECL_STMT_DECL (t); if (TREE_CODE (decl) == LABEL_DECL) finish_label_decl (DECL_NAME (decl)); @@ -7870,122 +7865,92 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) } case FOR_STMT: - { - prep_stmt (t); - - stmt = begin_for_stmt (); - tsubst_expr (FOR_INIT_STMT (t), args, complain, in_decl); - finish_for_init_stmt (stmt); - finish_for_cond (tsubst_expr (FOR_COND (t), - args, complain, in_decl), - stmt); - tmp = tsubst_expr (FOR_EXPR (t), args, complain, in_decl); - finish_for_expr (tmp, stmt); - tsubst_expr (FOR_BODY (t), args, complain, in_decl); - finish_for_stmt (stmt); - } + stmt = begin_for_stmt (); + tsubst_expr (FOR_INIT_STMT (t), args, complain, in_decl); + finish_for_init_stmt (stmt); + tmp = tsubst_expr (FOR_COND (t), args, complain, in_decl); + finish_for_cond (tmp, stmt); + tmp = tsubst_expr (FOR_EXPR (t), args, complain, in_decl); + finish_for_expr (tmp, stmt); + tsubst_expr (FOR_BODY (t), args, complain, in_decl); + finish_for_stmt (stmt); break; case WHILE_STMT: - { - prep_stmt (t); - stmt = begin_while_stmt (); - finish_while_stmt_cond (tsubst_expr (WHILE_COND (t), - args, complain, in_decl), - stmt); - tsubst_expr (WHILE_BODY (t), args, complain, in_decl); - finish_while_stmt (stmt); - } + stmt = begin_while_stmt (); + tmp = tsubst_expr (WHILE_COND (t), args, complain, in_decl); + finish_while_stmt_cond (tmp, stmt); + tsubst_expr (WHILE_BODY (t), args, complain, in_decl); + finish_while_stmt (stmt); break; case DO_STMT: - { - prep_stmt (t); - stmt = begin_do_stmt (); - tsubst_expr (DO_BODY (t), args, complain, in_decl); - finish_do_body (stmt); - finish_do_stmt (tsubst_expr (DO_COND (t), - args, complain, in_decl), - stmt); - } + stmt = begin_do_stmt (); + tsubst_expr (DO_BODY (t), args, complain, in_decl); + finish_do_body (stmt); + tmp = tsubst_expr (DO_COND (t), args, complain, in_decl); + finish_do_stmt (tmp, stmt); break; case IF_STMT: - { - prep_stmt (t); - stmt = begin_if_stmt (); - finish_if_stmt_cond (tsubst_expr (IF_COND (t), - args, complain, in_decl), - stmt); - tsubst_expr (THEN_CLAUSE (t), args, complain, in_decl); - finish_then_clause (stmt); - - if (ELSE_CLAUSE (t)) - { - begin_else_clause (stmt); - tsubst_expr (ELSE_CLAUSE (t), args, complain, in_decl); - finish_else_clause (stmt); - } + stmt = begin_if_stmt (); + tmp = tsubst_expr (IF_COND (t), args, complain, in_decl); + finish_if_stmt_cond (tmp, stmt); + tsubst_expr (THEN_CLAUSE (t), args, complain, in_decl); + finish_then_clause (stmt); - finish_if_stmt (stmt); - } + if (ELSE_CLAUSE (t)) + { + begin_else_clause (stmt); + tsubst_expr (ELSE_CLAUSE (t), args, complain, in_decl); + finish_else_clause (stmt); + } + + finish_if_stmt (stmt); break; case BIND_EXPR: - { - prep_stmt (t); - if (BIND_EXPR_BODY_BLOCK (t)) - stmt = begin_function_body (); - else - stmt = begin_compound_stmt (BIND_EXPR_TRY_BLOCK (t) - ? BCS_TRY_BLOCK : 0); + if (BIND_EXPR_BODY_BLOCK (t)) + stmt = begin_function_body (); + else + stmt = begin_compound_stmt (BIND_EXPR_TRY_BLOCK (t) + ? BCS_TRY_BLOCK : 0); - tsubst_expr (BIND_EXPR_BODY (t), args, complain, in_decl); + tsubst_expr (BIND_EXPR_BODY (t), args, complain, in_decl); - if (BIND_EXPR_BODY_BLOCK (t)) - finish_function_body (stmt); - else - finish_compound_stmt (stmt); - } + if (BIND_EXPR_BODY_BLOCK (t)) + finish_function_body (stmt); + else + finish_compound_stmt (stmt); break; case BREAK_STMT: - prep_stmt (t); finish_break_stmt (); break; case CONTINUE_STMT: - prep_stmt (t); finish_continue_stmt (); break; case SWITCH_STMT: - { - tree val; - - prep_stmt (t); - stmt = begin_switch_stmt (); - val = tsubst_expr (SWITCH_COND (t), args, complain, in_decl); - finish_switch_cond (val, stmt); - tsubst_expr (SWITCH_BODY (t), args, complain, in_decl); - finish_switch_stmt (stmt); - } + stmt = begin_switch_stmt (); + tmp = tsubst_expr (SWITCH_COND (t), args, complain, in_decl); + finish_switch_cond (tmp, stmt); + tsubst_expr (SWITCH_BODY (t), args, complain, in_decl); + finish_switch_stmt (stmt); break; case CASE_LABEL_EXPR: - prep_stmt (t); finish_case_label (tsubst_expr (CASE_LOW (t), args, complain, in_decl), tsubst_expr (CASE_HIGH (t), args, complain, in_decl)); break; case LABEL_EXPR: - prep_stmt (t); finish_label_stmt (DECL_NAME (LABEL_EXPR_LABEL (t))); break; case GOTO_EXPR: - prep_stmt (t); tmp = GOTO_DESTINATION (t); if (TREE_CODE (tmp) != LABEL_DECL) /* Computed goto's must be tsubst'd into. On the other hand, @@ -7998,7 +7963,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) break; case ASM_EXPR: - prep_stmt (t); tmp = finish_asm_stmt (ASM_VOLATILE_P (t), tsubst_expr (ASM_STRING (t), args, complain, in_decl), @@ -8009,7 +7973,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) break; case TRY_BLOCK: - prep_stmt (t); if (CLEANUP_P (t)) { stmt = begin_try_block (); @@ -8045,7 +8008,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) { tree decl; - prep_stmt (t); stmt = begin_handler (); if (HANDLER_PARMS (t)) { @@ -8065,7 +8027,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) break; case TAG_DEFN: - prep_stmt (t); tsubst (TREE_TYPE (t), args, complain, NULL_TREE); break; diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 61f751a..6b55880 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2196,7 +2196,6 @@ cp_update_decl_after_saving (tree fn, void init_tree (void) { - lang_gimplify_stmt = cp_gimplify_stmt; list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL); } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2e7d30e..92c52a9 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -563,6 +563,15 @@ should_carry_locus_p (tree stmt) return true; } +static void +annotate_one_with_locus (tree t, location_t locus) +{ + if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t))) + && ! EXPR_HAS_LOCATION (t) + && should_carry_locus_p (t)) + annotate_with_locus (t, locus); +} + void annotate_all_with_locus (tree *stmt_p, location_t locus) { @@ -583,10 +592,7 @@ annotate_all_with_locus (tree *stmt_p, location_t locus) abort (); #endif - if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t))) - && ! EXPR_HAS_LOCATION (t) - && should_carry_locus_p (t)) - annotate_with_locus (t, locus); + annotate_one_with_locus (t, locus); } } @@ -3558,6 +3564,10 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p, annotate_all_with_locus (&internal_pre, input_location); *expr_p = internal_pre; } + else if (TREE_CODE (*expr_p) == STATEMENT_LIST) + annotate_all_with_locus (expr_p, input_location); + else + annotate_one_with_locus (*expr_p, input_location); goto out; } -- 2.7.4