summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-07 06:55:51 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-07 06:55:51 +0000
commit41fb2c183baec4e1959faca92a3e79916b1c5af8 (patch)
tree26b71c56ba6d8b613dd53a45e0c6e5aa848ee50d
parentb83e87223f3b88c14509fdbf576d2fa737b13e2a (diff)
downloadgcc-41fb2c183baec4e1959faca92a3e79916b1c5af8.tar.gz
* c-common.h (prep_stmt): Declare.
(lang_expand_stmt): Likewise. * c-decl.c (lang_expand_stmt): Remove. * c-semantics.c (lang_expand_stmt): Define. (prep_stmt): New function. (expand_stmt): Handle common statement types here. * cp-tree.h (init_cp_semantics): Declare. (genrtl_try_block): Don't declare. (genrtl_handler): Likewise. (genrtl_catch_block): Likewise. (genrtl_ctor_stmt): Likewise. (genrtl_subobject): Likewise. (genrtl_do_poplevel): Likewise. (genrtl_named_return_value): Likewise. * lex.c (init_parse): Call init_cp_semantics. * semantics.c (genrtl_try_block): Give it internal linkage. (genrtl_handler): Likewise. (genrtl_catch_block): Likewise. (genrtl_ctor_stmt): Likewise. (genrtl_subobject): Likewise. (genrtl_do_poplevel): Likewise. (genrtl_named_return_value): Likewise. (lang_expand_stmt): Rename to ... (cp_expand_stmt): ... this. Only handle C++-specific nodes. (init_cp_semantics): Define. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36229 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-common.h5
-rw-r--r--gcc/c-decl.c11
-rw-r--r--gcc/c-semantics.c107
-rw-r--r--gcc/cp/ChangeLog20
-rw-r--r--gcc/cp/cp-tree.h8
-rw-r--r--gcc/cp/lex.c2
-rw-r--r--gcc/cp/semantics.c191
8 files changed, 193 insertions, 160 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fcf31dba503..1605acc4e4c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2000-09-06 Mark Mitchell <mark@codesourcery.com>
+
+ * c-common.h (prep_stmt): Declare.
+ (lang_expand_stmt): Likewise.
+ * c-decl.c (lang_expand_stmt): Remove.
+ * c-semantics.c (lang_expand_stmt): Define.
+ (prep_stmt): New function.
+ (expand_stmt): Handle common statement types here.
+
2000-09-07 Niibe Yutaka <gniibe@m17n.org>, Kaz Kojima <kkojima@rr.iij4u.or.jp>, Alexandre Oliva <aoliva@redhat.com>
* configure.in (sh-*-linux*): Added.
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 6f442c466c6..e995b9978e0 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -264,6 +264,9 @@ extern int (*lang_statement_code_p) PARAMS ((enum tree_code));
extern tree walk_stmt_tree PARAMS ((tree *,
walk_tree_fn,
void *));
+extern void prep_stmt PARAMS ((tree));
+extern void (*lang_expand_stmt) PARAMS ((tree));
+extern void expand_stmt PARAMS ((tree));
/* The variant of the C language being processed. Each C language
front-end defines this variable. */
@@ -585,8 +588,6 @@ extern int anon_aggr_type_p PARAMS ((tree));
extern void emit_local_var PARAMS ((tree));
extern void make_rtl_for_local_static PARAMS ((tree));
extern tree expand_cond PARAMS ((tree));
-extern tree expand_stmt PARAMS ((tree));
-extern tree lang_expand_stmt PARAMS ((tree));
extern void c_expand_return PARAMS ((tree));
extern tree c_expand_start_case PARAMS ((tree));
extern void do_case PARAMS ((tree, tree));
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index a5dc3d64e98..8b006577f94 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -7000,17 +7000,6 @@ do_case (low_value, high_value)
}
}
-/* Language specific handler of tree nodes used when generating RTL
- from a tree. */
-
-tree
-lang_expand_stmt (t)
- tree t ATTRIBUTE_UNUSED;
-{
- abort ();
- return NULL_TREE;
-}
-
/* Accessor to set the 'current_function_name_declared' flag. */
void
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index eea9f9209e5..8a4cf91c6c4 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -36,6 +36,10 @@ Boston, MA 02111-1307, USA. */
#include "output.h"
#include "timevar.h"
+/* If non-NULL, the address of a language-specific function for
+ expanding statements. */
+void (*lang_expand_stmt) PARAMS ((tree));
+
static tree prune_unused_decls PARAMS ((tree *, int *, void *));
/* Create an empty statement tree rooted at T. */
@@ -643,15 +647,110 @@ genrtl_decl_cleanup (decl, cleanup)
expand_decl_cleanup (decl, cleanup);
}
+/* We're about to expand T, a statement. Set up appropriate context
+ for the substitution. */
+
+void
+prep_stmt (t)
+ tree t;
+{
+ if (!STMT_LINENO_FOR_FN_P (t))
+ lineno = STMT_LINENO (t);
+ current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
+}
+
/* Generate the RTL for the statement T, its substatements, and any
other statements at its nesting level. */
-tree
+void
expand_stmt (t)
tree t;
{
- tree rval;
- rval = lang_expand_stmt (t);
- return rval;
+ while (t && t != error_mark_node)
+ {
+ int saved_stmts_are_full_exprs_p;
+
+ /* Set up context appropriately for handling this statement. */
+ saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
+ prep_stmt (t);
+
+ switch (TREE_CODE (t))
+ {
+ case RETURN_STMT:
+ genrtl_return_stmt (RETURN_EXPR (t));
+ break;
+
+ case EXPR_STMT:
+ genrtl_expr_stmt (EXPR_STMT_EXPR (t));
+ break;
+
+ case DECL_STMT:
+ genrtl_decl_stmt (t);
+ break;
+
+ case FOR_STMT:
+ genrtl_for_stmt (t);
+ break;
+
+ case WHILE_STMT:
+ genrtl_while_stmt (t);
+ break;
+
+ case DO_STMT:
+ genrtl_do_stmt (t);
+ break;
+
+ case IF_STMT:
+ genrtl_if_stmt (t);
+ break;
+
+ case COMPOUND_STMT:
+ genrtl_compound_stmt (t);
+ break;
+
+ case BREAK_STMT:
+ genrtl_break_stmt ();
+ break;
+
+ case CONTINUE_STMT:
+ genrtl_continue_stmt ();
+ break;
+
+ case SWITCH_STMT:
+ genrtl_switch_stmt (t);
+ break;
+
+ case CASE_LABEL:
+ genrtl_case_label (CASE_LOW (t), CASE_HIGH (t));
+ break;
+
+ case LABEL_STMT:
+ expand_label (LABEL_STMT_LABEL (t));
+ break;
+
+ case GOTO_STMT:
+ genrtl_goto_stmt (GOTO_DESTINATION (t));
+ break;
+
+ case ASM_STMT:
+ genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
+ ASM_OUTPUTS (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
+ break;
+
+ default:
+ if (lang_expand_stmt)
+ (*lang_expand_stmt) (t);
+ else
+ abort ();
+ break;
+ }
+
+ /* Restore saved state. */
+ current_stmt_tree ()->stmts_are_full_exprs_p =
+ saved_stmts_are_full_exprs_p;
+
+ /* Go on to the next statement in this scope. */
+ t = TREE_CHAIN (t);
+ }
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7f5b0143fea..396a03211f8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,25 @@
2000-09-06 Mark Mitchell <mark@codesourcery.com>
+ * cp-tree.h (init_cp_semantics): Declare.
+ (genrtl_try_block): Don't declare.
+ (genrtl_handler): Likewise.
+ (genrtl_catch_block): Likewise.
+ (genrtl_ctor_stmt): Likewise.
+ (genrtl_subobject): Likewise.
+ (genrtl_do_poplevel): Likewise.
+ (genrtl_named_return_value): Likewise.
+ * lex.c (init_parse): Call init_cp_semantics.
+ * semantics.c (genrtl_try_block): Give it internal linkage.
+ (genrtl_handler): Likewise.
+ (genrtl_catch_block): Likewise.
+ (genrtl_ctor_stmt): Likewise.
+ (genrtl_subobject): Likewise.
+ (genrtl_do_poplevel): Likewise.
+ (genrtl_named_return_value): Likewise.
+ (lang_expand_stmt): Rename to ...
+ (cp_expand_stmt): ... this. Only handle C++-specific nodes.
+ (init_cp_semantics): Define.
+
* decl.c (initialize_local_var): Remove RTL-generating code.
* semantics.c (genrtl_try_block): Fix formatting.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9fb04e52a37..f29b04b35e6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4286,6 +4286,7 @@ extern tree binfo_for_vbase PARAMS ((tree, tree));
extern void fixup_all_virtual_upcast_offsets PARAMS ((tree));
/* in semantics.c */
+extern void init_cp_semantics PARAMS ((void));
extern void finish_expr_stmt PARAMS ((tree));
extern tree begin_if_stmt PARAMS ((void));
extern void finish_if_stmt_cond PARAMS ((tree, tree));
@@ -4375,14 +4376,7 @@ extern void do_pushlevel PARAMS ((void));
extern tree do_poplevel PARAMS ((void));
extern void finish_mem_initializers PARAMS ((tree));
-extern void genrtl_try_block PARAMS ((tree));
-extern void genrtl_handler PARAMS ((tree));
-extern void genrtl_catch_block PARAMS ((tree));
-extern void genrtl_ctor_stmt PARAMS ((tree));
-extern void genrtl_subobject PARAMS ((tree));
-extern tree genrtl_do_poplevel PARAMS ((void));
extern void clear_out_block PARAMS ((void));
-extern void genrtl_named_return_value PARAMS ((void));
extern tree begin_global_stmt_expr PARAMS ((void));
extern tree finish_global_stmt_expr PARAMS ((tree));
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 1d6ca77168c..c9d56397259 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -714,10 +714,10 @@ init_parse (filename)
init_reswords ();
init_pragma ();
init_cp_pragma ();
-
init_spew ();
init_tree ();
init_cplus_expand ();
+ init_cp_semantics ();
add_c_tree_codes ();
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 643295ed8c8..e1a73cee6bc 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -50,6 +50,14 @@ static tree maybe_convert_cond PARAMS ((tree));
static tree simplify_aggr_init_exprs_r PARAMS ((tree *, int *, void *));
static void deferred_type_access_control PARAMS ((void));
static void emit_associated_thunks PARAMS ((tree));
+static void genrtl_try_block PARAMS ((tree));
+static void genrtl_handler PARAMS ((tree));
+static void genrtl_catch_block PARAMS ((tree));
+static void genrtl_ctor_stmt PARAMS ((tree));
+static void genrtl_subobject PARAMS ((tree));
+static tree genrtl_do_poplevel PARAMS ((void));
+static void genrtl_named_return_value PARAMS ((void));
+static void cp_expand_stmt PARAMS ((tree));
/* When parsing a template, LAST_TREE contains the last statement
parsed. These are chained together through the TREE_CHAIN field,
@@ -592,7 +600,8 @@ finish_case_label (low_value, high_value)
/* Generate the RTL for T, which is a TRY_BLOCK. */
-void genrtl_try_block (t)
+static void
+genrtl_try_block (t)
tree t;
{
if (CLEANUP_P (t))
@@ -731,7 +740,7 @@ finish_function_handler_sequence (try_block)
/* Generate the RTL for T, which is a HANDLER. */
-void
+static void
genrtl_handler (t)
tree t;
{
@@ -791,7 +800,7 @@ finish_handler_parms (decl, handler)
/* Generate the RTL for a CATCH_BLOCK. */
-void
+static void
genrtl_catch_block (type)
tree type;
{
@@ -825,7 +834,7 @@ finish_handler (blocks, handler)
/* Generate the RTL for T, which is a CTOR_STMT. */
-void
+static void
genrtl_ctor_stmt (t)
tree t;
{
@@ -991,7 +1000,7 @@ add_decl_stmt (decl)
/* Generate the RTL for a SUBOBJECT. */
-void
+static void
genrtl_subobject (cleanup)
tree cleanup;
{
@@ -1022,7 +1031,7 @@ finish_decl_cleanup (decl, cleanup)
/* Generate the RTL for a RETURN_INIT. */
-void
+static void
genrtl_named_return_value ()
{
tree decl;
@@ -2216,147 +2225,51 @@ finish_typeof (expr)
return TREE_TYPE (expr);
}
-/* We're about to expand T, a statement. Set up appropriate context
- for the substitution. */
-
-void
-prep_stmt (t)
- tree t;
-{
- if (!STMT_LINENO_FOR_FN_P (t))
- lineno = STMT_LINENO (t);
- current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
-}
-
/* Generate RTL for the statement T, and its substatements, and any
other statements at its nesting level. */
-tree
-lang_expand_stmt (t)
+static void
+cp_expand_stmt (t)
tree t;
{
- tree rval = NULL_TREE;
-
- while (t && t != error_mark_node)
+ switch (TREE_CODE (t))
{
- int saved_stmts_are_full_exprs_p;
+ case CLEANUP_STMT:
+ genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
+ break;
- /* Assume we'll have nothing to return. */
- rval = NULL_TREE;
+ case START_CATCH_STMT:
+ genrtl_catch_block (TREE_TYPE (t));
+ break;
- /* Set up context appropriately for handling this statement. */
- saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
- prep_stmt (t);
+ case CTOR_STMT:
+ genrtl_ctor_stmt (t);
+ break;
- switch (TREE_CODE (t))
- {
- case RETURN_STMT:
- genrtl_return_stmt (RETURN_EXPR (t));
- break;
-
- case EXPR_STMT:
- genrtl_expr_stmt (EXPR_STMT_EXPR (t));
- break;
-
- case DECL_STMT:
- genrtl_decl_stmt (t);
- break;
-
- case CLEANUP_STMT:
- genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
- break;
-
- case START_CATCH_STMT:
- genrtl_catch_block (TREE_TYPE (t));
- break;
-
- case CTOR_STMT:
- genrtl_ctor_stmt (t);
- break;
-
- case FOR_STMT:
- genrtl_for_stmt (t);
- break;
-
- case WHILE_STMT:
- genrtl_while_stmt (t);
- break;
-
- case DO_STMT:
- genrtl_do_stmt (t);
- break;
-
- case IF_STMT:
- genrtl_if_stmt (t);
- break;
-
- case COMPOUND_STMT:
- genrtl_compound_stmt (t);
- break;
-
- case BREAK_STMT:
- genrtl_break_stmt ();
- break;
-
- case CONTINUE_STMT:
- genrtl_continue_stmt ();
- break;
-
- case SWITCH_STMT:
- genrtl_switch_stmt (t);
- break;
-
- case CASE_LABEL:
- genrtl_case_label (CASE_LOW (t), CASE_HIGH (t));
- break;
-
- case LABEL_STMT:
- expand_label (LABEL_STMT_LABEL (t));
- break;
-
- case GOTO_STMT:
- genrtl_goto_stmt (GOTO_DESTINATION (t));
- break;
-
- case ASM_STMT:
- genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
- ASM_OUTPUTS (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
- break;
-
- case TRY_BLOCK:
- genrtl_try_block (t);
- break;
-
- case HANDLER:
- genrtl_handler (t);
- break;
-
- case SUBOBJECT:
- genrtl_subobject (SUBOBJECT_CLEANUP (t));
- break;
-
- case SCOPE_STMT:
- genrtl_scope_stmt (t);
- break;
-
- case RETURN_INIT:
- genrtl_named_return_value ();
- break;
-
- default:
- my_friendly_abort (19990810);
- break;
- }
+ case TRY_BLOCK:
+ genrtl_try_block (t);
+ break;
- /* Restore saved state. */
- current_stmt_tree ()->stmts_are_full_exprs_p =
- saved_stmts_are_full_exprs_p;
+ case HANDLER:
+ genrtl_handler (t);
+ break;
- /* Go on to the next statement in this scope. */
- t = TREE_CHAIN (t);
- }
+ case SUBOBJECT:
+ genrtl_subobject (SUBOBJECT_CLEANUP (t));
+ break;
+
+ case SCOPE_STMT:
+ genrtl_scope_stmt (t);
+ break;
- return rval;
+ case RETURN_INIT:
+ genrtl_named_return_value ();
+ break;
+
+ default:
+ my_friendly_abort (19990810);
+ break;
+ }
}
/* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
@@ -2630,3 +2543,11 @@ expand_body (fn)
timevar_pop (TV_EXPAND);
}
+
+/* Perform initialization related to this module. */
+
+void
+init_cp_semantics ()
+{
+ lang_expand_stmt = cp_expand_stmt;
+}