Commit f6b0b3db by Andreas Arnez Committed by Andreas Krebbel

[PR debug/67192] Fix C loops' back-jump location

gcc/c/ChangeLog:

	PR debug/67192
	* c-parser.c (c_parser_while_statement): Finish the loop before
	parsing ahead for misleading indentation.
	(c_parser_for_statement): Likewise.

gcc/testsuite/ChangeLog:

	PR debug/67192
	* gcc.dg/guality/pr67192.c: New test.

From-SVN: r230023
parent 0e657ecb
2015-11-09 Andreas Arnez <arnez@linux.vnet.ibm.com>
PR debug/67192
* c-parser.c (c_parser_while_statement): Finish the loop before
parsing ahead for misleading indentation.
(c_parser_for_statement): Likewise.
2015-11-08 Eric Botcazou <ebotcazou@adacore.com>
* c-decl.c (finish_struct): If the structure has reverse storage
......
......@@ -5437,13 +5437,13 @@ c_parser_while_statement (c_parser *parser, bool ivdep)
= get_token_indent_info (c_parser_peek_token (parser));
body = c_parser_c99_block_statement (parser);
c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
token_indent_info next_tinfo
= get_token_indent_info (c_parser_peek_token (parser));
warn_for_misleading_indentation (while_tinfo, body_tinfo, next_tinfo);
c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true);
add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
c_break_label = save_break;
c_cont_label = save_cont;
}
......@@ -5727,15 +5727,16 @@ c_parser_for_statement (c_parser *parser, bool ivdep)
body = c_parser_c99_block_statement (parser);
token_indent_info next_tinfo
= get_token_indent_info (c_parser_peek_token (parser));
warn_for_misleading_indentation (for_tinfo, body_tinfo, next_tinfo);
if (is_foreach_statement)
objc_finish_foreach_loop (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 ()));
token_indent_info next_tinfo
= get_token_indent_info (c_parser_peek_token (parser));
warn_for_misleading_indentation (for_tinfo, body_tinfo, next_tinfo);
c_break_label = save_break;
c_cont_label = save_cont;
}
......
2015-11-09 Andreas Arnez <arnez@linux.vnet.ibm.com>
PR debug/67192
* gcc.dg/guality/pr67192.c: New test.
2015-11-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/68248
......
/* PR debug/67192 */
/* { dg-do run } */
/* { dg-options "-g -Wmisleading-indentation" } */
volatile int cnt = 0;
__attribute__((noinline, noclone)) static int
last (void)
{
return ++cnt % 5 == 0;
}
__attribute__((noinline, noclone)) static void
do_it (void)
{
asm volatile ("" : : "r" (&cnt) : "memory");
}
__attribute__((noinline, noclone)) static void
f1 (void)
{
for (;; do_it())
{
if (last ())
break;
}
do_it (); /* { dg-final { gdb-test 27 "cnt" "5" } } */
}
__attribute__((noinline, noclone)) static void
f2 (void)
{
while (1)
{
if (last ())
break;
do_it ();
}
do_it (); /* { dg-final { gdb-test 39 "cnt" "10" } } */
}
void (*volatile fnp1) (void) = f1;
void (*volatile fnp2) (void) = f2;
int
main ()
{
asm volatile ("" : : "r" (&fnp1) : "memory");
asm volatile ("" : : "r" (&fnp2) : "memory");
fnp1 ();
fnp2 ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment