diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2020-09-19 07:32:35 -0700 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2020-09-19 13:54:16 -0700 |
commit | 3696a50beeb73f4ded8a584e76ee16f0bde109b9 (patch) | |
tree | 547aae764865eb453ea15100d01ddd72cae15773 /gcc/c/c-decl.c | |
parent | a85e5696a31cac8c14dde14f031e76480205f8a0 (diff) | |
download | gcc-3696a50beeb73f4ded8a584e76ee16f0bde109b9.zip gcc-3696a50beeb73f4ded8a584e76ee16f0bde109b9.tar.gz gcc-3696a50beeb73f4ded8a584e76ee16f0bde109b9.tar.bz2 |
Change C front end to emit structured loop and switch tree nodes.
2020-08-12 Sandra Loosemore <sandra@codesourcery.com>
gcc/c
* c-decl.c (c_break_label, c_cont_label): Delete, and replace
with...
(in_statement): New.
(start_function): Adjust for above change.
(c_push_function_context, c_pop_function_context): Likewise.
* c-lang.h (struct language_function): Likewise.
* c-objc-common.h (LANG_HOOKS_BLOCK_MAY_FALLTHRU): Define.
* c-parser.c (objc_foreach_break_label, objc_foreach_continue_label):
New.
(c_parser_statement_after_labels): Adjust calls to c_finish_bc_stmt.
(c_parser_switch_statement): Adjust break/switch context handling
and calls to renamed functions.
(c_parser_while_statement): Adjust break/switch context handling and
build a WHILE_STMT.
(c_parser_do_statement): Ditto, with DO_STMT respectively.
(c_parser_for_statement): Ditto, with FOR_STMT respectively.
(c_parser_omp_for_loop): Adjust break/switch context handling.
* c-tree.h (c_break_label, c_cont_label): Delete.
(IN_SWITCH_STMT, IN_ITERATION_STMT): Define.
(IN_OMP_BLOCK, IN_OMP_FOR, IN_OBJC_FOREACH): Define.
(in_statement, switch_statement_break_seen_p): Declare.
(c_start_case, c_finish_case): Renamed to...
(c_start_switch, c_finish_switch).
(c_finish_bc_stmt): Adjust arguments.
* c-typeck.c (build_function_call_vec): Don't try to print
statements with %qE format.
(struct c_switch): Rename switch_expr field to switch_stmt.
Add break_stmt_seen_p field.
(c_start_case): Rename to c_start_switch. Build a SWITCH_STMT
instead of a SWITCH_EXPR. Update for changes to struct c_switch.
(do_case): Update for changes to struct c_switch.
(c_finish_case): Rename to c_finish_switch. Update for changes to
struct c_switch and change of representation from SWITCH_EXPR to
SWITCH_STMT.
(c_finish_loop): Delete.
(c_finish_bc_stmt): Update to reflect changes to break/continue
state representation. Build a BREAK_STMT or CONTINUE_STMT instead
of a GOTO_EXPR except for objc foreach loops.
gcc/objc
* objc-act.c (objc_start_method_definition): Update to reflect
changes to break/continue state bookkeeping in C front end.
gcc/testsuite/
* gcc.dg/gomp/block-7.c: Update expected error message wording.
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 190c00b..8204db2 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -112,9 +112,9 @@ struct obstack parser_obstack; static GTY(()) struct stmt_tree_s c_stmt_tree; -/* State saving variables. */ -tree c_break_label; -tree c_cont_label; +/* Zero if we are not in an iteration or switch statement, otherwise + a bitmask. See bitmask definitions in c-tree.h. */ +unsigned char in_statement; /* A list of decls to be made automatically visible in each file scope. */ static GTY(()) tree visible_builtins; @@ -9163,10 +9163,8 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, warn_about_return_type = 0; c_switch_stack = NULL; - /* Indicate no valid break/continue context by setting these variables - to some non-null, non-label value. We'll notice and emit the proper - error message in c_finish_bc_stmt. */ - c_break_label = c_cont_label = size_zero_node; + /* Indicate no valid break/continue context. */ + in_statement = 0; decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL, &attributes, NULL, NULL, DEPRECATED_NORMAL); @@ -10167,8 +10165,7 @@ c_push_function_context (void) p->base.x_stmt_tree = c_stmt_tree; c_stmt_tree.x_cur_stmt_list = vec_safe_copy (c_stmt_tree.x_cur_stmt_list); - p->x_break_label = c_break_label; - p->x_cont_label = c_cont_label; + p->x_in_statement = in_statement; p->x_switch_stack = c_switch_stack; p->arg_info = current_function_arg_info; p->returns_value = current_function_returns_value; @@ -10207,8 +10204,7 @@ c_pop_function_context (void) c_stmt_tree = p->base.x_stmt_tree; p->base.x_stmt_tree.x_cur_stmt_list = NULL; - c_break_label = p->x_break_label; - c_cont_label = p->x_cont_label; + in_statement = p->x_in_statement; c_switch_stack = p->x_switch_stack; current_function_arg_info = p->arg_info; current_function_returns_value = p->returns_value; |