diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2011-05-27 17:43:44 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@gcc.gnu.org> | 2011-05-27 17:43:44 +0000 |
commit | 38e01f9ec96801f325e382746ba2d424adea5eee (patch) | |
tree | 308837cc489c3a37ca81ae52d342d7b9bd43b7c7 /gcc/c-family | |
parent | e330aa5b3568877fb26267fa0f277de320821b14 (diff) | |
download | gcc-38e01f9ec96801f325e382746ba2d424adea5eee.zip gcc-38e01f9ec96801f325e382746ba2d424adea5eee.tar.gz gcc-38e01f9ec96801f325e382746ba2d424adea5eee.tar.bz2 |
move TS_STATEMENT_LIST to be a substructure of TS_TYPED
move TS_STATEMENT_LIST to be a substructure of TS_TYPED
gcc/
* c-decl.c (c_push_function_context): Copy the current statement
list stack.
(add_stmt): Check building_stmt_list_p and push_stmt if necessary.
(finish_struct): Call building_stmt_list_p instead of checking
cur_stmt_list.
* c-parser.c (c_parser_postfix_expression): Likewise.
* c-typeck.c (c_end_compound_stmt): Likewise.
* print-tree.c (print_node) [STATEMENT_LIST]: Don't print TREE_CHAIN.
* tree-iterator.c (stmt_list_cache): Change to a VEC.
(alloc_stmt_list): Adjust for stmt_list_cache's new type.
(free_stmt_list): Likewise.
* tree.h (struct tree_statement_list): Include typed_tree instead
of tree_common.
* tree.c (initialize_tree_contains_struct): Mark TS_STATEMENT_LIST
as TS_TYPED instead of TS_COMMON.
gcc/c-family/
* c-common.h (struct stmt_tree_s) [x_cur_stmt_list]: Change to a VEC.
(stmt_list_stack): Define.
(cur_stmt_list): Adjust for new type of x_cur_stmt_list.
* c-semantics.c (push_stmt_list, pop_stmt_list): Likewise.
gcc/cp/
* cp-tree.h (building_stmt_tree): Delete.
* decl.c (save_function_data): Tweak initializer for x_cur_stmt_list.
(build_aggr_init_full_exprs): Call building_stmt_list_p
instead of building_stmt_tree.
(initialize_local_var): Likewise.
(finish_function): Likewise.
* decl2.c (finish_anon_union): Likewise.
* init.c (begin_init_stmts): Likewise.
(finish_init_stmts): Likewise.
(expand_aggr_init_1): Likewise.
* name-lookup.c (do_local_using_decl): Likewise.
(do_namespace_alias): Likewise.
(do_using_directive): Likewise.
(cp_emit_debug_info_for_using): Likewise.
* semantics.c (add_stmt): Assert that stmt_list_stack is non-empty.
From-SVN: r174343
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 16 | ||||
-rw-r--r-- | gcc/c-family/c-semantics.c | 19 |
3 files changed, 28 insertions, 14 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f15bd2f..557f896 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2011-05-27 Nathan Froyd <froydnj@codesourcery.com> + + * c-common.h (struct stmt_tree_s) [x_cur_stmt_list]: Change to a VEC. + (stmt_list_stack): Define. + (cur_stmt_list): Adjust for new type of x_cur_stmt_list. + * c-semantics.c (push_stmt_list, pop_stmt_list): Likewise. + 2011-05-26 Nathan Froyd <froydnj@codesourcery.com> * c-common.c (warning_candidate_p): Check for BLOCKs. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 65f8ad1..1b658b1 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -452,8 +452,8 @@ typedef enum ref_operator { /* Information about a statement tree. */ struct GTY(()) stmt_tree_s { - /* The current statement list being collected. */ - tree x_cur_stmt_list; + /* A stack of statement lists being collected. */ + VEC(tree,gc) *x_cur_stmt_list; /* In C++, Nonzero if we should treat statements as full expressions. In particular, this variable is no-zero if at the @@ -483,11 +483,17 @@ struct GTY(()) c_language_function { struct stmt_tree_s x_stmt_tree; }; +#define stmt_list_stack (current_stmt_tree ()->x_cur_stmt_list) + /* When building a statement-tree, this is the current statement list - being collected. It's TREE_CHAIN is a back-pointer to the previous - statement list. */ + being collected. We define it in this convoluted way, rather than + using VEC_last, because it must be an lvalue. */ + +#define cur_stmt_list \ + (*(VEC_address (tree, stmt_list_stack) \ + + VEC_length (tree, stmt_list_stack) - 1)) -#define cur_stmt_list (current_stmt_tree ()->x_cur_stmt_list) +#define building_stmt_list_p() (!VEC_empty (tree, stmt_list_stack)) /* Language-specific hooks. */ diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c index a5bd9ba..cb0f2be 100644 --- a/gcc/c-family/c-semantics.c +++ b/gcc/c-family/c-semantics.c @@ -38,8 +38,7 @@ push_stmt_list (void) { tree t; t = alloc_stmt_list (); - TREE_CHAIN (t) = cur_stmt_list; - cur_stmt_list = t; + VEC_safe_push (tree, gc, stmt_list_stack, t); return t; } @@ -48,21 +47,23 @@ push_stmt_list (void) tree pop_stmt_list (tree t) { - tree u = cur_stmt_list, chain; + tree u = NULL_TREE; /* Pop statement lists until we reach the target level. The extra nestings will be due to outstanding cleanups. */ while (1) { - chain = TREE_CHAIN (u); - TREE_CHAIN (u) = NULL_TREE; - if (chain) - STATEMENT_LIST_HAS_LABEL (chain) |= STATEMENT_LIST_HAS_LABEL (u); + u = VEC_pop (tree, stmt_list_stack); + if (!VEC_empty (tree, stmt_list_stack)) + { + tree x = VEC_last (tree, stmt_list_stack); + STATEMENT_LIST_HAS_LABEL (x) |= STATEMENT_LIST_HAS_LABEL (u); + } if (t == u) break; - u = chain; } - cur_stmt_list = chain; + + gcc_assert (u != NULL_TREE); /* If the statement list is completely empty, just return it. This is just as good small as build_empty_stmt, with the advantage that |