glcpp: Track the actual version instead of just the version_resolved flag
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 9 Aug 2016 21:31:49 +0000 (14:31 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 10 Aug 2016 23:42:02 +0000 (16:42 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
src/compiler/glsl/glcpp/glcpp-parse.y
src/compiler/glsl/glcpp/glcpp.h

index ca376d983fff3c819dbb682bfbf17440efb39f93..05a76c7b082893ecf5fb241816eee9a739caab49 100644 (file)
@@ -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);
 
index 07eaf684beef863dcbffeb85bc4d072a14a08595..9f35b0556c3a741b487bbea2e6001122473f7aa2 100644 (file)
@@ -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;