glsl/glcpp: Fix glcpp to catch garbage after #if 1 ... #else
authorCarl Worth <cworth@cworth.org>
Thu, 12 Jun 2014 17:39:39 +0000 (10:39 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 9 Jul 2014 19:05:13 +0000 (12:05 -0700)
commit98c0e3c7834f8a99f7641aa14b2bab5221aa66db
tree513fa5c5d1dfcfaf7205317b7b0bbfbfe0094631
parent1d862a0b39dfd2723aac6c64f9a7609c205b3cdc
glsl/glcpp: Fix glcpp to catch garbage after #if 1 ... #else

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).

This fixes the following Khronos GLES3 CTS tests:

tokens_after_else_vertex
        tokens_after_else_fragment

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/glcpp-parse.y
src/glsl/glcpp/glcpp.h
src/glsl/glcpp/tests/103-garbage-after-else-0.c [new file with mode: 0644]
src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected [new file with mode: 0644]
src/glsl/glcpp/tests/103-garbage-after-else.c [deleted file]
src/glsl/glcpp/tests/103-garbage-after-else.c.expected [deleted file]
src/glsl/glcpp/tests/123-garbage-after-else-1.c [new file with mode: 0644]
src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected [new file with mode: 0644]