Mesa (master): glsl/glcpp: Swallow empty #pragma directives.

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 7 23:08:47 UTC 2014


Module: Mesa
Branch: master
Commit: a48ff781c1cac00ad432edf88fafa44e667fa90f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a48ff781c1cac00ad432edf88fafa44e667fa90f

Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jul  2 10:32:46 2014 -0700

glsl/glcpp: Swallow empty #pragma directives.

Previously, we were passing these through, just like any other pragma. But the
downstream compiler was tripping up on them. It seems easier to swallow these
in the preprocessor and not pass them on at all rather than fixing the
downstream compiler.

This fixes the following Khronos GLES3 CTS tests:

	preprocessor.pragmas.pragma_vertex
	preprocessor.pragmas.pragma_fragment

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/glcpp/glcpp-lex.l                       |    6 ++++++
 src/glsl/glcpp/tests/127-pragma-empty.c.expected |    2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 430abd4..aeaf8ab 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -287,6 +287,12 @@ HEXADECIMAL_INTEGER	0[xX][0-9a-fA-F]+[uU]?
 	RETURN_STRING_TOKEN (VERSION_TOKEN);
 }
 
+	/* Swallow empty #pragma directives, (to avoid confusing the
+	 * downstream compiler). */
+<HASH>pragma{HSPACE}*/[\r\n] {
+	BEGIN INITIAL;
+}
+
 	/* glcpp doesn't handle #extension, #version, or #pragma directives.
 	 * Simply pass them through to the main compiler's lexer/parser. */
 <HASH>(extension|pragma)[^\r\n]* {
diff --git a/src/glsl/glcpp/tests/127-pragma-empty.c.expected b/src/glsl/glcpp/tests/127-pragma-empty.c.expected
index 89fe08e..92371a0 100644
--- a/src/glsl/glcpp/tests/127-pragma-empty.c.expected
+++ b/src/glsl/glcpp/tests/127-pragma-empty.c.expected
@@ -1,3 +1,3 @@
  
 
-#pragma
+




More information about the mesa-commit mailing list