[Mesa-dev] [PATCH] glsl: Properly lex extra tokens when handling # directives.

Kenneth Graunke kenneth at whitecape.org
Wed Jun 11 22:04:09 PDT 2014


Without this, in the <PP> state, we would hit Flex's default rule, which
prints tokens to stdout, rather than returning them as tokens.

This manifested as a weird bug where shaders with semicolons after
extension directives, such as:

   #extension GL_foo_bar : enable;

would print semicolons to the screen, but otherwise compile just fine
(even though this is illegal).

Fixes Piglit's extension-semicolon.frag test.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/glsl_lexer.ll | 1 +
 1 file changed, 1 insertion(+)

Not sure if this should be a stable candidate or not.  It rejects more
shaders.  But printing random text on the console is really unexpected
as well...

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 6c3f9b6..ef30bcb 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -236,6 +236,7 @@ HASH		^{SPC}#{SPC}
 				    return INTCONSTANT;
 				}
 <PP>\n				{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
+<PP>.				{ return yytext[0]; }
 
 \n		{ yylineno++; yycolumn = 0; }
 
-- 
2.0.0



More information about the mesa-dev mailing list