Re: [PATCH] [checkpatch.pl] ctx_statement_block #if/#else/#endif fix
From: Andy Whitcroft
Date: Wed Jun 11 2014 - 05:57:20 EST
On Wed, Jun 11, 2014 at 10:16:40AM +0100, Andy Whitcroft wrote:
> It doesn't seem right to remove the restore of the state. If you
> consider the effect of an #if/#else/#endif combination the state of the
> statement parser should be reset to the state at #if at the #else as the
> code there is an alternative for the code in the other branch(s) of the
> preprocessor, either is a continuation of the statement in progress when
> reached. This contrived example should make it clear we need to
> restore:
>
> c = (d +
> #if A
> a)
> #else
> b)
> #endif
>
>
> That said it appears to be doing something wrong in your example.
>
> /me will have a poke and get back to you.
Ok, the fundamental issue seems to have been an off by one thinko in the
attempt to restore the state to the previous level ($@array is the index
of the late element not the length of the array). The patch below seems
to sort out the issue. Could you give it a try and confirm it covers
your primary cases, and if so I will push it to akpm.
Thanks.
-apw