glsl: Parse 0 as a preprocessor INTCONSTANT
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 8 Nov 2016 19:14:49 +0000 (11:14 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 10 Nov 2016 18:57:59 +0000 (10:57 -0800)
This allows a more reasonable error message for '#version 0' of

    0:1(10): error: GLSL 0.00 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

instead of

    0:1(10): error: syntax error, unexpected $undefined, expecting INTCONSTANT

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97420
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: mesa-stable@lists.freedesktop.org
Cc: Juan A. Suarez Romero <jasuarez@igalia.com>
Cc: Karol Herbst <karolherbst@gmail.com>
src/compiler/glsl/glsl_lexer.ll

index b473af7845c031e330330dccf3cc65ee233287ef..0e722cbfba3aea5456f719f43345dc6ea940ef4f 100644 (file)
@@ -253,6 +253,10 @@ HASH               ^{SPC}#{SPC}
                                    yylval->n = strtol(yytext, NULL, 10);
                                    return INTCONSTANT;
                                }
+<PP>0                          {
+                                   yylval->n = 0;
+                                   return INTCONSTANT;
+                               }
 <PP>\n                         { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
 <PP>.                          { return yytext[0]; }