Commit 009ed910 by Steven Bosscher

c-common.h (lang_statement_code_p): Remove declaration.

2003-04-09  Steven Bosscher  <steven@gcc.gnu.org>

	* c-common.h (lang_statement_code_p): Remove declaration.
	(statement_code_p): Ditto.
	(c_common_stmt_codes): Define; list of c-common statement codes.
	(statement_code_p): New extern declaration.
	(STATEMENT_CODE_P): Define.
	(INIT_STATEMENT_CODES): Define.
	* c-common.c (statement_code_p): Kill the function, declare
	as an array of bools instead.
	(lang_statement_code_p): Remove.
	(walk_stmt_tree): Use STATEMENT_CODE_P not statement_code_p.
	(c_safe_from_p): Ditto.
	* c-objc-common.c (c_objc_common_init): Use INIT_STATEMENT_CODES
	to initialize the statement_code_p array.
	* tree-inline.c (walk_tree): Use STATEMENT_CODE_P instead of
	statement_code_p.
	(copy_tree_r): Ditto.
	* cp/cp-tree.h (cp_stmt_codes): Define; list of C++ specific
	statement tree codes.
	* cp/lex.c (cxx_init): Add missing print line break.  Use
	INIT_STATEMENT_CODES to initialize the statement_code_p array.
	* cp/parser.c (cp_parser_statement): Use STATEMENT_CODE_P
	instead of statement_code_p.
	* cp/pt.c (tsubst_expr): Ditto.
	* cp/tree.c (verify_stmt_tree_r): Ditto.
	(cp_statement_code_p): Remove.
	(init_tree): Don't set lang_statement_code_p, it's gone.

From-SVN: r65422
parent 23cac885
2003-04-09 Steven Bosscher <steven@gcc.gnu.org>
* c-common.h (lang_statement_code_p): Remove declaration.
(statement_code_p): Ditto.
(c_common_stmt_codes): Define; list of c-common statement codes.
(statement_code_p): New extern declaration.
(STATEMENT_CODE_P): Define.
(INIT_STATEMENT_CODES): Define.
* c-common.c (statement_code_p): Kill the function, declare
as an array of bools instead.
(lang_statement_code_p): Remove.
(walk_stmt_tree): Use STATEMENT_CODE_P not statement_code_p.
(c_safe_from_p): Ditto.
* c-objc-common.c (c_objc_common_init): Use INIT_STATEMENT_CODES
to initialize the statement_code_p array.
* tree-inline.c (walk_tree): Use STATEMENT_CODE_P instead of
statement_code_p.
(copy_tree_r): Ditto.
* cp/cp-tree.h (cp_stmt_codes): Define; list of C++ specific
statement tree codes.
* cp/lex.c (cxx_init): Add missing print line break. Use
INIT_STATEMENT_CODES to initialize the statement_code_p array.
* cp/parser.c (cp_parser_statement): Use STATEMENT_CODE_P
instead of statement_code_p.
* cp/pt.c (tsubst_expr): Ditto.
* cp/tree.c (verify_stmt_tree_r): Ditto.
(cp_statement_code_p): Remove.
(init_tree): Don't set lang_statement_code_p, it's gone.
2003-04-09 Dan Nicolaescu <dann@ics.uci.edu>
Zack Weinberg <zack@codesourcery.com>
......
......@@ -187,6 +187,11 @@ enum c_language_kind c_language;
tree c_global_trees[CTI_MAX];
/* TRUE if a code represents a statement. The front end init
langhook should take care of initialization of this array. */
bool statement_code_p[MAX_TREE_CODES];
/* Nonzero if we can read a PCH file now. */
int allow_pch = 1;
......@@ -682,10 +687,6 @@ tree *ridpointers;
tree (*make_fname_decl) PARAMS ((tree, int));
/* If non-NULL, the address of a language-specific function that
returns 1 for language-specific statement codes. */
int (*lang_statement_code_p) PARAMS ((enum tree_code));
/* 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) PARAMS ((void));
......@@ -3927,41 +3928,6 @@ expand_tree_builtin (function, params, coerced_params)
return NULL_TREE;
}
/* Returns nonzero if CODE is the code for a statement. */
int
statement_code_p (code)
enum tree_code code;
{
switch (code)
{
case CLEANUP_STMT:
case EXPR_STMT:
case COMPOUND_STMT:
case DECL_STMT:
case IF_STMT:
case FOR_STMT:
case WHILE_STMT:
case DO_STMT:
case RETURN_STMT:
case BREAK_STMT:
case CONTINUE_STMT:
case SCOPE_STMT:
case SWITCH_STMT:
case GOTO_STMT:
case LABEL_STMT:
case ASM_STMT:
case FILE_STMT:
case CASE_LABEL:
return 1;
default:
if (lang_statement_code_p)
return (*lang_statement_code_p) (code);
return 0;
}
}
/* Walk the statement tree, rooted at *tp. Apply FUNC to all the
sub-trees of *TP in a pre-order traversal. FUNC is called with the
DATA and the address of each sub-tree. If FUNC returns a non-NULL
......@@ -3997,7 +3963,7 @@ walk_stmt_tree (tp, func, data)
return NULL_TREE;
/* Skip subtrees below non-statement nodes. */
if (!statement_code_p (TREE_CODE (*tp)))
if (!STATEMENT_CODE_P (TREE_CODE (*tp)))
return NULL_TREE;
/* Call the function. */
......@@ -4011,7 +3977,7 @@ walk_stmt_tree (tp, func, data)
/* FUNC may have modified the tree, recheck that we're looking at a
statement node. */
code = TREE_CODE (*tp);
if (!statement_code_p (code))
if (!STATEMENT_CODE_P (code))
return NULL_TREE;
/* Visit the subtrees unless FUNC decided that there was nothing
......@@ -4386,7 +4352,7 @@ c_safe_from_p (target, exp)
}
/* For any statement, we must follow the statement-chain. */
if (statement_code_p (TREE_CODE (exp)) && TREE_CHAIN (exp))
if (STATEMENT_CODE_P (TREE_CODE (exp)) && TREE_CHAIN (exp))
return safe_from_p (target, TREE_CHAIN (exp), /*top_p=*/0);
/* Assume everything else is safe. */
......
......@@ -305,7 +305,6 @@ struct c_language_function GTY(()) {
/* Language-specific hooks. */
extern int (*lang_statement_code_p) PARAMS ((enum tree_code));
extern void (*lang_expand_stmt) PARAMS ((tree));
extern void (*lang_expand_decl_stmt) PARAMS ((tree));
extern void (*lang_expand_function_end) PARAMS ((void));
......@@ -326,7 +325,6 @@ extern void add_decl_stmt PARAMS ((tree));
extern tree add_scope_stmt PARAMS ((int, int));
extern void finish_stmt_tree PARAMS ((tree *));
extern int statement_code_p PARAMS ((enum tree_code));
extern tree walk_stmt_tree PARAMS ((tree *,
walk_tree_fn,
void *));
......@@ -1152,6 +1150,28 @@ enum c_tree_code {
#undef DEFTREECODE
#define c_common_stmt_codes \
CLEANUP_STMT, EXPR_STMT, COMPOUND_STMT, \
DECL_STMT, IF_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, RETURN_STMT, \
BREAK_STMT, CONTINUE_STMT, SCOPE_STMT, \
SWITCH_STMT, GOTO_STMT, LABEL_STMT, \
ASM_STMT, FILE_STMT, CASE_LABEL
/* TRUE if a code represents a statement. The front end init
langhook should take care of initialization of this array. */
extern bool statement_code_p[MAX_TREE_CODES];
#define STATEMENT_CODE_P(CODE) statement_code_p[(int) (CODE)]
#define INIT_STATEMENT_CODES(STMT_CODES) \
do { \
unsigned int i; \
memset (&statement_code_p, 0, sizeof (statement_code_p)); \
for (i = 0; i < ARRAY_SIZE (STMT_CODES); i++) \
statement_code_p[STMT_CODES[i]] = true; \
} while (0)
extern void genrtl_do_pushlevel PARAMS ((void));
extern void genrtl_goto_stmt PARAMS ((tree));
extern void genrtl_expr_stmt PARAMS ((tree));
......
......@@ -244,6 +244,12 @@ c_warn_unused_global_decl (decl)
bool
c_objc_common_init ()
{
static const enum tree_code stmt_codes[] = {
c_common_stmt_codes
};
INIT_STATEMENT_CODES (stmt_codes);
c_init_decl_processing ();
if (c_common_init () == false)
......
......@@ -902,6 +902,10 @@ enum cplus_tree_code {
};
#undef DEFTREECODE
#define cp_stmt_codes \
CTOR_INITIALIZER, TRY_BLOCK, HANDLER, \
EH_SPEC_BLOCK, USING_STMT, TAG_DEFN
enum languages { lang_c, lang_cplusplus, lang_java };
/* Macros to make error reporting functions' lives easier. */
......
......@@ -409,6 +409,13 @@ init_cp_pragma ()
bool
cxx_init (void)
{
static const enum tree_code stmt_codes[] = {
c_common_stmt_codes,
cp_stmt_codes
};
INIT_STATEMENT_CODES (stmt_codes);
input_filename = "<internal>";
init_reswords ();
......
......@@ -5660,7 +5660,7 @@ cp_parser_statement (cp_parser* parser)
}
/* Set the line number for the statement. */
if (statement && statement_code_p (TREE_CODE (statement)))
if (statement && STATEMENT_CODE_P (TREE_CODE (statement)))
STMT_LINENO (statement) = statement_line_number;
}
......
......@@ -7569,7 +7569,7 @@ tsubst_expr (t, args, complain, in_decl)
if (processing_template_decl)
return tsubst_copy (t, args, complain, in_decl);
if (!statement_code_p (TREE_CODE (t)))
if (!STATEMENT_CODE_P (TREE_CODE (t)))
return tsubst_copy_and_build (t, args, complain, in_decl);
switch (TREE_CODE (t))
......
......@@ -49,7 +49,6 @@ static tree build_target_expr PARAMS ((tree, tree));
static tree count_trees_r PARAMS ((tree *, int *, void *));
static tree verify_stmt_tree_r PARAMS ((tree *, int *, void *));
static tree find_tree_r PARAMS ((tree *, int *, void *));
extern int cp_statement_code_p PARAMS ((enum tree_code));
static tree handle_java_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
static tree handle_com_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
......@@ -1120,27 +1119,6 @@ is_aggr_type_2 (t1, t2)
return IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2);
}
/* Returns nonzero if CODE is the code for a statement. */
int
cp_statement_code_p (code)
enum tree_code code;
{
switch (code)
{
case CTOR_INITIALIZER:
case TRY_BLOCK:
case HANDLER:
case EH_SPEC_BLOCK:
case USING_STMT:
case TAG_DEFN:
return 1;
default:
return 0;
}
}
#define PRINT_RING_SIZE 4
const char *
......@@ -1275,7 +1253,7 @@ verify_stmt_tree_r (tp, walk_subtrees, data)
htab_t *statements = (htab_t *) data;
void **slot;
if (!statement_code_p (TREE_CODE (t)))
if (!STATEMENT_CODE_P (TREE_CODE (t)))
return NULL_TREE;
/* If this statement is already present in the hash table, then
......@@ -2406,7 +2384,6 @@ cp_end_inlining (fn)
void
init_tree ()
{
lang_statement_code_p = cp_statement_code_p;
list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
}
......
......@@ -1588,7 +1588,7 @@ walk_tree (tp, func, data, htab_)
interesting below this point in the tree. */
if (!walk_subtrees)
{
if (statement_code_p (code) || code == TREE_LIST
if (STATEMENT_CODE_P (code) || code == TREE_LIST
|| (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp))
/* But we still need to check our siblings. */
WALK_SUBTREE_TAIL (TREE_CHAIN (*tp));
......@@ -1613,7 +1613,7 @@ walk_tree (tp, func, data, htab_)
#ifndef INLINER_FOR_JAVA
/* Set lineno here so we get the right instantiation context
if we call instantiate_decl from inlinable_function_p. */
if (statement_code_p (code) && !STMT_LINENO_FOR_FN_P (*tp))
if (STATEMENT_CODE_P (code) && !STMT_LINENO_FOR_FN_P (*tp))
lineno = STMT_LINENO (*tp);
#endif /* not INLINER_FOR_JAVA */
......@@ -1632,7 +1632,7 @@ walk_tree (tp, func, data, htab_)
#ifndef INLINER_FOR_JAVA
/* For statements, we also walk the chain so that we cover the
entire statement tree. */
if (statement_code_p (code))
if (STATEMENT_CODE_P (code))
{
if (code == DECL_STMT
&& DECL_STMT_DECL (*tp)
......@@ -1823,7 +1823,7 @@ copy_tree_r (tp, walk_subtrees, data)
if (code == PARM_DECL || code == TREE_LIST
#ifndef INLINER_FOR_JAVA
|| (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp)
|| statement_code_p (code))
|| STATEMENT_CODE_P (code))
TREE_CHAIN (*tp) = chain;
/* For now, we don't update BLOCKs when we make copies. So, we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment