+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>
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;
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));
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
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. */
/* 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
}
/* 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. */
/* 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));
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 *));
#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));
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)
};
#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. */
c_register_pragma ("GCC", "implementation", handle_pragma_implementation);
c_register_pragma ("GCC", "java_exceptions", handle_pragma_java_exceptions);
}
-
+\f
/* Initialize the C++ front end. This function is very sensitive to
the exact order that things are done here. It would be nice if the
initialization done by this routine were moved to its subroutines,
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 ();
}
/* 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;
}
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))
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 *));
return 0;
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;
- }
-}
\f
#define PRINT_RING_SIZE 4
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
void
init_tree ()
{
- lang_statement_code_p = cp_statement_code_p;
list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
}
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));
#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 */
#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)
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