diff options
author | Kenneth Graunke <[email protected]> | 2010-08-04 16:24:39 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2010-08-04 23:37:19 -0700 |
commit | f4239872c9cb56d1e5735b62ea53bedf3f39dfb0 (patch) | |
tree | 5f792ae46426e05b8cfdd8547235a6582ac95d85 /src/glsl/glcpp/glcpp-parse.y | |
parent | d65135a7661c320c618151df0a94c852dc9bc621 (diff) |
glcpp: Ignore #if and #elif expressions when skipping.
Fixes glcpp test cases 073 and 074, as well as piglit test
xonotic-vs-generic-diffuse.vert.
Diffstat (limited to 'src/glsl/glcpp/glcpp-parse.y')
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.y | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index e19da432eec..df1a649d9bc 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -215,7 +215,15 @@ control_line: talloc_free ($2); } | HASH_IF conditional_tokens NEWLINE { - _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + /* If we're skipping to the next #elif/#else case or to #endif, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) { + _glcpp_parser_skip_stack_push_if (parser, & @1, 0); + parser->skip_stack->type = SKIP_TO_ENDIF; + } else { + _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + } } | HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); @@ -228,7 +236,13 @@ control_line: _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF conditional_tokens NEWLINE { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); + /* If we just finished a non-skipped #if/#ifdef/#ifndef block, + * don't bother expanding or parsing the expression. + */ + if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) + parser->skip_stack->type = SKIP_TO_ENDIF; + else + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); } | HASH_ELIF NEWLINE { /* #elif without an expression results in a warning if the |