aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.h
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2000-09-07 01:36:11 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2000-09-07 01:36:11 +0000
commitae499ccea4f2eee460c8612d920755773cacfe47 (patch)
tree1ae8ce0d3f4f58cfa7b33b9fac7c1209e34d27a7 /gcc/c-common.h
parent4f4b88d0832c7279722b5dee73d9ce9f1704452f (diff)
downloadgcc-ae499ccea4f2eee460c8612d920755773cacfe47.zip
gcc-ae499ccea4f2eee460c8612d920755773cacfe47.tar.gz
gcc-ae499ccea4f2eee460c8612d920755773cacfe47.tar.bz2
Move statement-tree facilities from C++ to C front-end.
* c-common.h (c_tree_index): Add CTI_VOID_ZERO. (void_zero_node): New macro. (struct stmt_tree_s): New type. (stmt_tree): New typedef. (struct language_function): New type. (last_tree): New macro. (last_expr_type): Likewise. (walk_tree_fn): New typedef. (current_stmt_tree): New function. (begin_stmt_tree): Likewise. (add_stmt): Likewise. (finish_stmt_tree): Likewise. (statement_code_p): Likewise. (lang_statement_code_p): New variable. (walk_stmt_tree): New function. (STMT_IS_FULL_EXPR_P): New macro. * c-common.c (lang_statement_code_p): New variable. (c_common_nodes_and_builtins): Initialize void_zero_node. (statement_code_p): New function. (walk_stmt_tree): Likewise. * c-decl.c (language_function): Rename to ... (c_language_function): ... this. Include language_function. (push_c_function_context): Adjust accordingly. (pop_c_function_context): Likewise. (mark_c_function_context): Likewise. (current_stmt_tree): Define. * c-semantics.c (begin_stmt_tree): New function. (add_stmt): Likewise. (prune_unused_decls): Likewise. (finish_stmt_tree): Likewise. Move statement-tree facilities from C++ to C front-end. * cp-tree.h (cp_tree_index): Remove CPTI_VOID_ZERO. (void_zero_node): Remove. (stmt_tree): Likewise. (scope_chain): Adjust. (language_function): Rename to cp_language_function. (cp_function_chain): Adjust. (current_stmt_tree): Remove. (last_tree): Likewise. (last_expr_type): Likewise. (struct lang_decl): Adjust. (STMT_IS_FULL_EXPR_P): Remove. (add_tree): Remove. (begin_stmt_tree): Likewise. (finish_stmt_tree): Likewise. (walk_tree_fn): Likewise. (walk_stmt_tree): Likewise. * class.c (finish_struct): Replace use of add_tree with add_stmt. * decl.c (mark_stmt_tree): Adjust type. (init_decl_processing): Don't build void_zero_node. (initialize_local_var): Adjust usage of current_stmt_tree. (finish_enum): Use add_stmt, not add_tree. (save_function_data): Adjust use of language_function. (finish_constructor_body): Use add_stmt, not add_tree. (finish_destructor_body): Likewise. (push_cp_function_context): Adjust use of language_function. (pop_cp_function_context): Likewise. (mark_lang_function): Likewise. (mark_cp_function_context): Likewise. * init.c (build_aggr_init): Adjust use of current_stmt_tree. (build_vec_init): Likewise. * semantics.c (SET_LAST_STMT): Remove. (RECHAIN_STMTS): Don't use it. (stmts_are_full_exprs_p): Adjust use of current_stmt_tree. (current_stmt_tree): Define. (add_tree): Remove. (finish_goto_stmt): Use add_stmt, not add_tree. (finish_expr_stmt): Likewise. (begin_if_stmt): Likewise. (finish_then_clause): Likewise. (begin_while_stmt): Likewise. (begin_do_stmt): Likewise. (finish_return_stmt): Likewise. (begin_for_stmt): Likewise. (finish_break_stmt): Likewise. (finish_continue_stmt): Likewise. (begin_switch_stmt): Likewise. (finish_case_label): Likewise. (begin_try_block): Likewise. (begin_function_try_block): Likewise. (begin_handler): Likewise. (begin_catch_block): Likewise. (begin_compound_stmt): Likewise. (begin_asm_stmt): Likewise. (finish_asm_stmt): Likewise. (finish_label_stmt): Likewise. (add_decl_stmt): Likewise. (finish_subobject): Likewise. (finish_decl_cleanup): Likewise. (finish_named_return_value): Likewise. (setup_vtbl_ptr): Likewise. (add_scope_stmt): Likewise. (finish_stmt_expr): Likewise. (prune_unused_decls): Remove. (begin_stmt_tree): Likewise. (finish_stmt_tree): Likewise. (prep_stmt): Adjust use of current_stmt_tree. (lang_expand_stmt): Likewise. * tree.c (statement_code_p): Remove. (cp_statement_code_p): New function. (walk_stmt_tree): Remove. (init_tree): Set lang_statement_code_p. From-SVN: r36221
Diffstat (limited to 'gcc/c-common.h')
-rw-r--r--gcc/c-common.h76
1 files changed, 74 insertions, 2 deletions
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 7b4912c..6f442c4 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -147,6 +147,8 @@ enum c_tree_index
CTI_PRETTY_FUNCTION_ID,
CTI_FUNC_ID,
+ CTI_VOID_ZERO,
+
CTI_MAX
};
@@ -187,6 +189,9 @@ enum c_tree_index
#define pretty_function_id_node c_global_trees[CTI_PRETTY_FUNCTION_ID]
#define func_id_node c_global_trees[CTI_FUNC_ID]
+/* A node for `((void) 0)'. */
+#define void_zero_node c_global_trees[CTI_VOID_ZERO]
+
extern tree c_global_trees[CTI_MAX];
typedef enum c_language_kind
@@ -198,6 +203,68 @@ typedef enum c_language_kind
}
c_language_kind;
+/* Information about a statement tree. */
+
+struct stmt_tree_s {
+ /* The last statement added to the tree. */
+ tree x_last_stmt;
+ /* The type of the last expression statement. (This information is
+ needed to implement the statement-expression extension.) */
+ tree x_last_expr_type;
+ /* In C++, Non-zero if we should treat statements as full
+ expressions. In particular, this variable is no-zero if at the
+ end of a statement we should destroy any temporaries created
+ during that statement. Similarly, if, at the end of a block, we
+ should destroy any local variables in this block. Normally, this
+ variable is non-zero, since those are the normal semantics of
+ C++.
+
+ However, in order to represent aggregate initialization code as
+ tree structure, we use statement-expressions. The statements
+ within the statement expression should not result in cleanups
+ being run until the entire enclosing statement is complete.
+
+ This flag has no effect in C. */
+ int stmts_are_full_exprs_p;
+};
+
+typedef struct stmt_tree_s *stmt_tree;
+
+/* Global state pertinent to the current function. Some C dialects
+ extend this structure with additional fields. */
+
+struct language_function {
+ /* While we are parsing the function, this contains information
+ about the statement-tree that we are building. */
+ struct stmt_tree_s x_stmt_tree;
+};
+
+/* When building a statement-tree, this is the last statement added to
+ the tree. */
+
+#define last_tree (current_stmt_tree ()->x_last_stmt)
+
+/* The type of the last expression-statement we have seen. */
+
+#define last_expr_type (current_stmt_tree ()->x_last_expr_type)
+
+/* The type of a function that walks over tree structure. */
+
+typedef tree (*walk_tree_fn) PARAMS ((tree *,
+ int *,
+ void *));
+
+extern stmt_tree current_stmt_tree PARAMS ((void));
+extern void begin_stmt_tree PARAMS ((tree *));
+extern void add_stmt PARAMS ((tree));
+extern void finish_stmt_tree PARAMS ((tree *));
+
+extern int statement_code_p PARAMS ((enum tree_code));
+extern int (*lang_statement_code_p) PARAMS ((enum tree_code));
+extern tree walk_stmt_tree PARAMS ((tree *,
+ walk_tree_fn,
+ void *));
+
/* The variant of the C language being processed. Each C language
front-end defines this variable. */
@@ -337,8 +404,13 @@ extern tree build_va_arg PARAMS ((tree, tree));
extern int self_promoting_args_p PARAMS ((tree));
extern tree simple_type_promotes_to PARAMS ((tree));
-/* These macros provide convenient access to the various _STMT nodes
- created when parsing template declarations. */
+/* These macros provide convenient access to the various _STMT nodes. */
+
+/* Nonzero if this statement should be considered a full-expression,
+ i.e., if temporaries created during this statement should have
+ their destructors run at the end of this statement. (In C, this
+ will always be false, since there are no destructors.) */
+#define STMT_IS_FULL_EXPR_P(NODE) TREE_LANG_FLAG_1 ((NODE))
/* IF_STMT accessors. These give access to the condtion of the if
statement, the then block of the if statement, and the else block