Ping: https://gcc.gnu.org/ml/gcc-patches/2015-10/msg02393.html
On Fri, Oct 23 2015, Andreas Arnez wrote: > After parsing an unconditional "while"- or "for"-loop, the C front-end > generates a backward-goto statement and implicitly sets its location to > the current input_location. But in some cases the parser peeks ahead > first, such that input_location already points to the line after the > loop and the generated backward-goto gets the wrong line number. > > One way this can occur is with a loop body consisting of an "if" > statement, because then the parser peeks for an optional "else" before > finishing the loop. > > Another way occurs since r223098 ("Implement -Wmisleading-indentation"), > even with a loop body enclosed in braces. This is because the check for > misleading indentation always peeks ahead one token as well. > > This patch adds a new parameter to c_finish_loop that expclitly > specifies the location to be used for the loop iteration. All calls to > c_finish_loop are adjusted accordingly. > > gcc/c/ChangeLog: > > PR debug/67192 > * c-typeck.c (c_finish_loop): Replace implicit use of > input_location by new parameter iter_locus. > * c-tree.h (c_finish_loop): Adjust prototype. > * c-array-notation.c (fix_builtin_array_notation_fn): Explicitly > pass input_location as the new parameter to c_finish_loop. > (build_array_notation_expr): Likewise. > (fix_conditional_array_notations_1): Likewise. > (fix_array_notation_expr): Likewise. > (fix_array_notation_call_expr): Likewise. > * c-parser.c (c_parser_while_statement): Choose iter_locus > depending on whether the loop body is enclosed in braces, and pass > it to c_finish_loop. > (c_parser_for_statement): Likewise. > (c_parser_do_statement): Use the final semicolon's location for > iter_locus and pass it to c_finish_loop. > > gcc/testsuite/ChangeLog: > > PR debug/67192 > * gcc.dg/guality/pr67192.c: New test.