From: Ian Romanick Date: Tue, 9 Aug 2016 21:31:49 +0000 (-0700) Subject: glcpp: Track the actual version instead of just the version_resolved flag X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eda6349346616f3a45ca2d03e2c1a3da956df6b3;p=mesa.git glcpp: Track the actual version instead of just the version_resolved flag Signed-off-by: Ian Romanick Reviewed-by: Timothy Arceri Cc: mesa-stable@lists.freedesktop.org --- diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y index ca376d983ff..05a76c7b082 100644 --- a/src/compiler/glsl/glcpp/glcpp-parse.y +++ b/src/compiler/glsl/glcpp/glcpp-parse.y @@ -396,13 +396,13 @@ control_line_success: _glcpp_parser_skip_stack_pop (parser, & @1); } NEWLINE | HASH_TOKEN VERSION_TOKEN integer_constant NEWLINE { - if (parser->version_resolved) { + if (parser->version != 0) { glcpp_error(& @1, parser, "#version must appear on the first line"); } _glcpp_parser_handle_version_declaration(parser, $3, NULL, true); } | HASH_TOKEN VERSION_TOKEN integer_constant IDENTIFIER NEWLINE { - if (parser->version_resolved) { + if (parser->version != 0) { glcpp_error(& @1, parser, "#version must appear on the first line"); } _glcpp_parser_handle_version_declaration(parser, $3, $4, true); @@ -1346,7 +1346,7 @@ glcpp_parser_create(glcpp_extension_iterator extensions, void *state, gl_api api parser->extensions = extensions; parser->state = state; parser->api = api; - parser->version_resolved = false; + parser->version = 0; parser->has_new_line_number = 0; parser->new_line_number = 1; @@ -2280,10 +2280,10 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio const char *es_identifier, bool explicitly_set) { - if (parser->version_resolved) + if (parser->version != 0) return; - parser->version_resolved = true; + parser->version = version; add_builtin_define (parser, "__VERSION__", version); diff --git a/src/compiler/glsl/glcpp/glcpp.h b/src/compiler/glsl/glcpp/glcpp.h index 07eaf684bee..9f35b0556c3 100644 --- a/src/compiler/glsl/glcpp/glcpp.h +++ b/src/compiler/glsl/glcpp/glcpp.h @@ -206,7 +206,7 @@ struct glcpp_parser { glcpp_extension_iterator extensions; void *state; gl_api api; - bool version_resolved; + unsigned version; bool has_new_line_number; int new_line_number; bool has_new_source_number;