From e032e4ad5a3f73dffb1a8babcfd333954a574ffa Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Mar 2016 19:03:11 -0800 Subject: [PATCH] glcpp: Fix locations when encounting "#". We were failing to reset our location tracking when encountering a NEWLINE in the 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 Reviewed-by: Iago Toral Quiroga --- src/compiler/glsl/glcpp/glcpp-lex.l | 3 +++ .../glsl/glcpp/tests/146-version-first-hash.c.expected | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/glcpp/glcpp-lex.l b/src/compiler/glsl/glcpp/glcpp-lex.l index 071918e5692..d09441aac88 100644 --- a/src/compiler/glsl/glcpp/glcpp-lex.l +++ b/src/compiler/glsl/glcpp/glcpp-lex.l @@ -320,6 +320,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? {NEWLINE} { BEGIN INITIAL; + yyextra->space_tokens = 0; + yylineno++; + yycolumn = 0; RETURN_TOKEN_NEVER_SKIP (NEWLINE); } diff --git a/src/compiler/glsl/glcpp/tests/146-version-first-hash.c.expected b/src/compiler/glsl/glcpp/tests/146-version-first-hash.c.expected index 2872090333d..e8e449793fd 100644 --- a/src/compiler/glsl/glcpp/tests/146-version-first-hash.c.expected +++ b/src/compiler/glsl/glcpp/tests/146-version-first-hash.c.expected @@ -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 -- 2.30.2