On 10/12/2015 04:04 PM, Andreas Arnez wrote:
Since r223098 ("Implement -Wmisleading-indentation") the backward-jump
generated for a C while- or for-loop can get the wrong line number.
This is because the check for misleading indentation peeks ahead one
token, advancing input_location to after the loop, and then
c_finish_loop() creates the back-jump and calls add_stmt(), which
assigns input_location to the statement by default.

This patch swaps the check for misleading indentation with the finishing
of the loop, such that input_location still has the right value at the
time of any invocations of add_stmt().

One could argue that peek_token should not have an effect on input_location, and in fact cpp_peek_token seems to take steps that this does not happen, but it looks like c_parser_peek_token does not use that mechanism. Still,

gcc/testsuite/ChangeLog:

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

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.

This fix looks simple enough. Ok. (Might want to add noclone to the testcase attributes).


Bernd

Reply via email to