glsl: invalidate float suffixes for GLSL 1.10 and GLSL ES 1.00
authorLars Hamre <chemecse@gmail.com>
Tue, 29 Mar 2016 00:42:14 +0000 (20:42 -0400)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 30 Mar 2016 04:26:34 +0000 (21:26 -0700)
Float suffixes are not allowed in GLSL 1.10 nor GLSL ES 1.00.

Fixes the following piglit tests:
tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-capital-f.vert
tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-f.vert`

v2: modify error message
v3: parse the float instead of returning an ERROR_TOK
v4: (by Ken) Change to is_version(120, 300) to avoid breaking ES3
    shaders; update commit message accordingly.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81585
Signed-off-by: Lars Hamre <chemecse@gmail.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl/glsl_lexer.ll

index 883c58f0da9d99b874d2a2c61ebb1f4ec8e875e9..5492045f7c3ab57a74c387630c13fe2a6c97c685 100644 (file)
@@ -472,6 +472,13 @@ layout             {
 \.[0-9]+([eE][+-]?[0-9]+)?[fF]?                |
 [0-9]+\.([eE][+-]?[0-9]+)?[fF]?                |
 [0-9]+[eE][+-]?[0-9]+[fF]?             {
+                           struct _mesa_glsl_parse_state *state = yyextra;
+                           char suffix = yytext[strlen(yytext) - 1];
+                           if (!state->is_version(120, 300) &&
+                               (suffix == 'f' || suffix == 'F')) {
+                               _mesa_glsl_error(yylloc, state,
+                                                "Float suffixes are invalid in GLSL 1.10");
+                           }
                            yylval->real = _mesa_strtof(yytext, NULL);
                            return FLOATCONSTANT;
                        }