On Thu, Jun 12, 2014 at 12:58 PM, Carl Worth <cwo...@cworth.org> wrote: > Previously, a line such as: > > #else garbage > > would flag an error if it followed "#if 0", but not if it followed "#if 1". > > We fix this by setting a new bit of state (lexing_else) that allows the lexer > to defer switching to the <SKIP> start state until after the NEWLINE following > the #else directive. > > A new test case is added for: > > #if 1 > #else garbage > #endif > > which was untested before, (and did not generate the desired error). > --- > > Matt Turner <matts...@gmail.com> writes: >> The preprocessor is one of the only bits that uses tabs. I'd rather we >> stick with that, or convert the whole thing. > > Thanks for the catch. There are a handful of lines indented with spaces that > have managed to sneak in, but I might as well not add more. So I've fixed > that. Also, here in v2, instead of adding a lexing_else bit next to lexing_if, > instead I'm reusing the original bit and renaming it to lexing_directive. > > src/glsl/glcpp/glcpp-lex.l | 25 > +++++++++++----------- > src/glsl/glcpp/glcpp-parse.y | 6 +++--- > src/glsl/glcpp/glcpp.h | 2 +- > src/glsl/glcpp/tests/103-garbage-after-else-0.c | 3 +++ > .../tests/103-garbage-after-else-0.c.expected | 4 ++++ > src/glsl/glcpp/tests/103-garbage-after-else.c | 3 --- > .../glcpp/tests/103-garbage-after-else.c.expected | 4 ---- > src/glsl/glcpp/tests/123-garbage-after-else-1.c | 3 +++ > .../tests/123-garbage-after-else-1.c.expected | 4 ++++ > 9 files changed, 31 insertions(+), 23 deletions(-) > create mode 100644 src/glsl/glcpp/tests/103-garbage-after-else-0.c > create mode 100644 src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected > delete mode 100644 src/glsl/glcpp/tests/103-garbage-after-else.c > delete mode 100644 src/glsl/glcpp/tests/103-garbage-after-else.c.expected > create mode 100644 src/glsl/glcpp/tests/123-garbage-after-else-1.c > create mode 100644 src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected > > diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l > index 188e454..d5fb087 100644 > --- a/src/glsl/glcpp/glcpp-lex.l > +++ b/src/glsl/glcpp/glcpp-lex.l > @@ -137,14 +137,15 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? > * 2. The skip_stack is NULL meaning that we've reached > * the last #endif. > * > - * 3. The lexing_if bit is set. This indicates that we > - * are lexing the expression following an "#if" of > - * "#elif". Even inside an "#if 0" we need to lex this > - * expression so the parser can correctly update the > - * skip_stack state. > + * 3. The lexing_directive bit is set. This indicates that we are
This regressed from 4 to 3. :) Reviewed-by: Matt Turner <matts...@gmail.com> _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev