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.
This commit is contained in:
Kenneth Graunke
2010-08-04 16:24:39 -07:00
parent d65135a766
commit f4239872c9
2 changed files with 144 additions and 116 deletions
+16 -2
View File
@@ -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