glcpp: Fix locations when encounting "#<NEWLINE>".
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 9 Mar 2016 03:03:11 +0000 (19:03 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 10 Mar 2016 19:23:26 +0000 (11:23 -0800)
We were failing to reset our location tracking when encountering a
NEWLINE in the <HASH> state.  Rip the code from the <*>{NEWLINE} rule,
which handles this properly.

Also, update 146-version-first-hash.c to have proper expectations.
When I introduced the test, I didn't verify that the line/column
numbers were correct, and it turns out they varied based on the type
of newline ending.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94447
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/compiler/glsl/glcpp/glcpp-lex.l
src/compiler/glsl/glcpp/tests/146-version-first-hash.c.expected

index 071918e56923b490b25390774963f78dac33c995..d09441aac8801a4d45c7dfe2c9a3eba0eb0ee3f8 100644 (file)
@@ -320,6 +320,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
 
 <HASH>{NEWLINE} {
        BEGIN INITIAL;
+       yyextra->space_tokens = 0;
+       yylineno++;
+       yycolumn = 0;
        RETURN_TOKEN_NEVER_SKIP (NEWLINE);
 }
 
index 2872090333d6324eb3eb0bfdbd7d6c611ab55c7f..e8e449793fda764535a8a41d30dd6a5033867e9b 100644 (file)
@@ -1,3 +1,3 @@
-0:1(3): preprocessor error: #version must appear on the first line
+0:2(1): preprocessor error: #version must appear on the first line