From 34f7e761bc61d3086c1e4e42285c31678b256107 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 20 Sep 2017 16:19:15 -0500 Subject: glsl/parser: Track built-in types using the glsl_type directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without the lexer changes, tests/glslparsertest/glsl2/tex_rect-02.frag fails. Before this change, the parser would determine that sampler2DRect is not a valid type because the call to state->symbols->get_type() in ast_type_specifier::glsl_type() would return NULL. Since ast_type_specifier::glsl_type() is now going to return the glsl_type pointer that it received from the lexer, it doesn't have an opportunity to generate an error. text data bss dec hex filename 8255243 268856 294072 8818171 868dfb 32-bit i965_dri.so before 8255291 268856 294072 8818219 868e2b 32-bit i965_dri.so after 7815195 345592 420592 8581379 82f103 64-bit i965_dri.so before 7815339 345592 420592 8581523 82f193 64-bit i965_dri.so after Signed-off-by: Ian Romanick Reviewed-by: Nicolai Hähnle --- src/compiler/glsl/glsl_lexer.ll | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/compiler/glsl/glsl_lexer.ll') diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll index 5dad6eeb042..d2278ba01d6 100644 --- a/src/compiler/glsl/glsl_lexer.ll +++ b/src/compiler/glsl/glsl_lexer.ll @@ -132,18 +132,23 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *, /** * Like DEPRECATED_ES_KEYWORD, but for types */ -#define DEPRECATED_ES_TYPE(gtype) \ +#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype) \ do { \ if (yyextra->is_version(0, 300)) { \ - _mesa_glsl_error(yylloc, yyextra, \ - "illegal use of reserved word `%s'", yytext); \ - return ERROR_TOK; \ - } else { \ - yylval->type = gtype; \ + _mesa_glsl_error(yylloc, yyextra, \ + "illegal use of reserved word `%s'", yytext); \ + return ERROR_TOK; \ + } else if (alt_expr) { \ + yylval->type = gtype; \ return BASIC_TYPE_TOK; \ + } else { \ + return classify_identifier(yyextra, yytext, yyleng, yylval); \ } \ } while (0) +#define DEPRECATED_ES_TYPE(gtype) \ + DEPRECATED_ES_TYPE_WITH_ALT(true, gtype) + static int literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, YYSTYPE *lval, YYLTYPE *lloc, int base) @@ -619,9 +624,9 @@ dmat4x4 TYPE_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, gl fvec2 KEYWORD(110, 100, 0, 0, FVEC2); fvec3 KEYWORD(110, 100, 0, 0, FVEC3); fvec4 KEYWORD(110, 100, 0, 0, FVEC4); -sampler2DRect DEPRECATED_ES_TYPE(glsl_type::sampler2DRect_type); +sampler2DRect DEPRECATED_ES_TYPE_WITH_ALT(yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRect_type); sampler3DRect KEYWORD(110, 100, 0, 0, SAMPLER3DRECT); -sampler2DRectShadow DEPRECATED_ES_TYPE(glsl_type::sampler2DRectShadow_type); +sampler2DRectShadow DEPRECATED_ES_TYPE_WITH_ALT(yyextra->ARB_texture_rectangle_enable, glsl_type::sampler2DRectShadow_type); sizeof KEYWORD(110, 100, 0, 0, SIZEOF); cast KEYWORD(110, 100, 0, 0, CAST); namespace KEYWORD(110, 100, 0, 0, NAMESPACE); -- cgit v1.2.3