diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-04-26 17:38:33 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-04-26 17:38:33 +0200 |
commit | f179b64e3ab013ff04e705953d33a2f82de6b086 (patch) | |
tree | 52464894da7f7ffd9b288bcb2b44f8dd5e1958b7 /gcc/c/c-parser.c | |
parent | 6b3a5e8a3d18c8a954c6e99072fe1859977fafbd (diff) | |
download | gcc-f179b64e3ab013ff04e705953d33a2f82de6b086.zip gcc-f179b64e3ab013ff04e705953d33a2f82de6b086.tar.gz gcc-f179b64e3ab013ff04e705953d33a2f82de6b086.tar.bz2 |
re PR debug/90197 (Cannot step through simple loop at -O -g)
PR debug/90197
* c-tree.h (c_finish_loop): Add 2 further location_t arguments.
* c-parser.c (c_parser_while_statement): Adjust c_finish_loop caller.
(c_parser_do_statement): Likewise.
(c_parser_for_statement): Likewise. Formatting fixes.
* c-typeck.c (c_finish_loop): Add COND_LOCUS and INCR_LOCUS arguments,
emit DEBUG_BEGIN_STMTs if needed.
From-SVN: r270606
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r-- | gcc/c/c-parser.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 741d172..854cd6c 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6001,7 +6001,8 @@ c_parser_while_statement (c_parser *parser, bool ivdep, unsigned short unroll, location_t loc_after_labels; bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE); body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels); - c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true); + c_finish_loop (loc, loc, cond, UNKNOWN_LOCATION, NULL, body, + c_break_label, c_cont_label, true); add_stmt (c_end_compound_stmt (loc, block, flag_isoc99)); c_parser_maybe_reclassify_token (parser); @@ -6046,6 +6047,7 @@ c_parser_do_statement (c_parser *parser, bool ivdep, unsigned short unroll) c_break_label = save_break; new_cont = c_cont_label; c_cont_label = save_cont; + location_t cond_loc = c_parser_peek_token (parser)->location; cond = c_parser_paren_condition (parser); if (ivdep && cond != error_mark_node) cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, @@ -6059,7 +6061,8 @@ c_parser_do_statement (c_parser *parser, bool ivdep, unsigned short unroll) build_int_cst (integer_type_node, unroll)); if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) c_parser_skip_to_end_of_block_or_statement (parser); - c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false); + c_finish_loop (loc, cond_loc, cond, UNKNOWN_LOCATION, NULL, body, + new_break, new_cont, false); add_stmt (c_end_compound_stmt (loc, block, flag_isoc99)); } @@ -6132,7 +6135,9 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, /* Silence the bogus uninitialized warning. */ tree collection_expression = NULL; location_t loc = c_parser_peek_token (parser)->location; - location_t for_loc = c_parser_peek_token (parser)->location; + location_t for_loc = loc; + location_t cond_loc = UNKNOWN_LOCATION; + location_t incr_loc = UNKNOWN_LOCATION; bool is_foreach_statement = false; gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR)); token_indent_info for_tinfo @@ -6166,7 +6171,8 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, c_parser_consume_token (parser); is_foreach_statement = true; if (check_for_loop_decls (for_loc, true) == NULL_TREE) - c_parser_error (parser, "multiple iterating variables in fast enumeration"); + c_parser_error (parser, "multiple iterating variables in " + "fast enumeration"); } else check_for_loop_decls (for_loc, flag_isoc99); @@ -6196,7 +6202,8 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, c_parser_consume_token (parser); is_foreach_statement = true; if (check_for_loop_decls (for_loc, true) == NULL_TREE) - c_parser_error (parser, "multiple iterating variables in fast enumeration"); + c_parser_error (parser, "multiple iterating variables in " + "fast enumeration"); } else check_for_loop_decls (for_loc, flag_isoc99); @@ -6218,15 +6225,18 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, c_parser_consume_token (parser); is_foreach_statement = true; if (! lvalue_p (init_expression)) - c_parser_error (parser, "invalid iterating variable in fast enumeration"); - object_expression = c_fully_fold (init_expression, false, NULL); + c_parser_error (parser, "invalid iterating variable in " + "fast enumeration"); + object_expression + = c_fully_fold (init_expression, false, NULL); } else { ce = convert_lvalue_to_rvalue (loc, ce, true, false); init_expression = ce.value; c_finish_expr_stmt (loc, init_expression); - c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); + c_parser_skip_until_found (parser, CPP_SEMICOLON, + "expected %<;%>"); } } } @@ -6235,18 +6245,19 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, gcc_assert (!parser->objc_could_be_foreach_context); if (!is_foreach_statement) { + cond_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_SEMICOLON)) { if (ivdep) { - c_parser_error (parser, "missing loop condition in loop with " - "%<GCC ivdep%> pragma"); + c_parser_error (parser, "missing loop condition in loop " + "with %<GCC ivdep%> pragma"); cond = error_mark_node; } else if (unroll) { - c_parser_error (parser, "missing loop condition in loop with " - "%<GCC unroll%> pragma"); + c_parser_error (parser, "missing loop condition in loop " + "with %<GCC unroll%> pragma"); cond = error_mark_node; } else @@ -6275,11 +6286,13 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, /* Parse the increment expression (the third expression in a for-statement). In the case of a foreach-statement, this is the expression that follows the 'in'. */ + loc = incr_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) { if (is_foreach_statement) { - c_parser_error (parser, "missing collection in fast enumeration"); + c_parser_error (parser, + "missing collection in fast enumeration"); collection_expression = error_mark_node; } else @@ -6288,8 +6301,8 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, else { if (is_foreach_statement) - collection_expression = c_fully_fold (c_parser_expression (parser).value, - false, NULL); + collection_expression + = c_fully_fold (c_parser_expression (parser).value, false, NULL); else { struct c_expr ce = c_parser_expression (parser); @@ -6312,10 +6325,14 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll, body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels); if (is_foreach_statement) - objc_finish_foreach_loop (loc, object_expression, collection_expression, body, c_break_label, c_cont_label); + objc_finish_foreach_loop (for_loc, object_expression, + collection_expression, body, c_break_label, + c_cont_label); else - c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true); - add_stmt (c_end_compound_stmt (loc, block, flag_isoc99 || c_dialect_objc ())); + c_finish_loop (for_loc, cond_loc, cond, incr_loc, incr, body, + c_break_label, c_cont_label, true); + add_stmt (c_end_compound_stmt (for_loc, block, + flag_isoc99 || c_dialect_objc ())); c_parser_maybe_reclassify_token (parser); token_indent_info next_tinfo |