[Mesa-dev] [PATCH] glcpp: Don't use a lookahead for empty pragmas.

Kenneth Graunke kenneth at whitecape.org
Fri Aug 15 18:32:59 PDT 2014

Using alternatives with multiple characters in a lookahead pattern
appears to cause Flex to write past the end of an internal state array.

We don't actually need to do that - we can just make our empty pragma
rule eat the NEWLINE and return it, rather than ensuring one exists but
leaving it as the next thing to be processed.

Fixes Piglit's 16385-consecutive-chars and
17000-consecutive-chars-identifier tests.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82472
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: Carl Worth <cworth at cworth.org>
 src/glsl/glcpp/glcpp-lex.l | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 98d500e..eac41c8 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -290,8 +290,9 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	/* Swallow empty #pragma directives, (to avoid confusing the
 	 * downstream compiler). */
-<HASH>pragma{HSPACE}*/{NEWLINE} {
 	/* glcpp doesn't handle #extension, #version, or #pragma directives.

More information about the mesa-dev mailing list