The lexer was insisting that there be at least one character after "#pragma" and before the end of the line. This caused an error for a line consisting only of "#pragma" which volates at least the following sentence from the GLSL ES Specification 3.00.4:
The scope as well as the effect of the optimize and debug pragmas is implementation-dependent except that their use must not generate an error. [Page 12 (Page 28 of PDF)] and likely the following sentence from that specification and also in GLSLangSpec 4.30.6: If an implementation does not recognize the tokens following #pragma, then it will ignore that pragma. Add a "make check" test to ensure no future regressions. This change fixes at least part of the following Khronos GLES3 CTS test: preprocessor.pragmas.pragma_vertex --- src/glsl/glcpp/glcpp-lex.l | 2 +- src/glsl/glcpp/tests/127-pragma-empty.c | 3 +++ src/glsl/glcpp/tests/127-pragma-empty.c.expected | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/glsl/glcpp/tests/127-pragma-empty.c create mode 100644 src/glsl/glcpp/tests/127-pragma-empty.c.expected diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 2b818dc..88e2818 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -180,7 +180,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? /* glcpp doesn't handle #extension, #version, or #pragma directives. * Simply pass them through to the main compiler's lexer/parser. */ -{HASH}(extension|pragma)[^\n]+ { +{HASH}(extension|pragma)[^\n]* { if (parser->commented_newlines) BEGIN NEWLINE_CATCHUP; yylval->str = ralloc_strdup (yyextra, yytext); diff --git a/src/glsl/glcpp/tests/127-pragma-empty.c b/src/glsl/glcpp/tests/127-pragma-empty.c new file mode 100644 index 0000000..0f9b0b3 --- /dev/null +++ b/src/glsl/glcpp/tests/127-pragma-empty.c @@ -0,0 +1,3 @@ +/* It seems an odd (and particularly useless) thing to have an empty pragma, + * but we probably shouldn't trigger an error in this case. */ +#pragma diff --git a/src/glsl/glcpp/tests/127-pragma-empty.c.expected b/src/glsl/glcpp/tests/127-pragma-empty.c.expected new file mode 100644 index 0000000..957daff --- /dev/null +++ b/src/glsl/glcpp/tests/127-pragma-empty.c.expected @@ -0,0 +1,4 @@ + + +#pragma + -- 2.0.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev