On 11/04/2015 09:18 AM, 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 occurred after r223098 ("Implement
-Wmisleading-indentation"), even with a loop body enclosed in braces.
This was because the check for misleading indentation always peeks ahead
one token as well.

This patch avoids the use of input_location and sets the location of the
backward-goto to the start of the loop body instead, or, if there is no
loop body, to the start of the loop.

gcc/c/ChangeLog:

        PR debug/67192
        * c-typeck.c (c_finish_loop): For unconditional loops, set the
        location of the backward-goto to the start of the loop body.

gcc/testsuite/ChangeLog:

        PR debug/67192
        * gcc.dg/guality/pr67192.c (f3, f4): New functions.
        (main): Invoke them.
Also OK. And please consider using those tests with the C++ compiler to see if it's suffering from the same problem.

Thanks again!

jeff

Reply via email to