aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-06-19 12:34:23 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-06-19 12:34:23 -0700
commit7c34ced1a25f62ed12b1bf1158167fe157b60ae7 (patch)
tree8c9a0bb986a33bc83bc0dbbec28fa39603c3a2c6 /gcc/cp
parentebca59c355524893ef3facf6ad12074e4661348e (diff)
downloadgcc-7c34ced1a25f62ed12b1bf1158167fe157b60ae7.zip
gcc-7c34ced1a25f62ed12b1bf1158167fe157b60ae7.tar.gz
gcc-7c34ced1a25f62ed12b1bf1158167fe157b60ae7.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-gimplify.c181
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/pt.c155
-rw-r--r--gcc/cp/tree.c1
5 files changed, 164 insertions, 184 deletions
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 <rth@redhat.com>
+
+ * 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 <rth@redhat.com>
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);
}