summaryrefslogtreecommitdiff
path: root/glcpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-06-21 12:20:22 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-06-21 12:41:05 -0700
commit332fc47dc0998ac8e0a47e1ecded8829e712bde6 (patch)
tree2ce53905e7a76bbe911ab8c44e42b2dc6c186fd8 /glcpp
parent74704e80c69f400f7712aed4287a84adc13bfbed (diff)
glcpp: Accept #elif without an expression if the expression doesn't matter.
Issue a warning. nVidia's compiler seems to accept this; apparently GCC < 4.4 did as well: http://gcc.gnu.org/gcc-4.4/porting_to.html
Diffstat (limited to 'glcpp')
-rw-r--r--glcpp/glcpp-parse.y11
1 files changed, 11 insertions, 0 deletions
diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y
index 37c2f97..c314e95 100644
--- a/glcpp/glcpp-parse.y
+++ b/glcpp/glcpp-parse.y
@@ -249,6 +249,17 @@ control_line:
_token_list_append_list (expanded, $2);
glcpp_parser_lex_from (parser, expanded);
}
+| HASH_ELIF NEWLINE {
+ /* #elif without an expression results in a warning if the
+ * condition doesn't matter (we just handled #if 1 or such)
+ * but an error otherwise. */
+ if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) {
+ parser->skip_stack->type = SKIP_TO_ENDIF;
+ glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
+ } else {
+ glcpp_error(& @1, parser, "#elif needs an expression");
+ }
+ }
| HASH_ELSE NEWLINE {
_glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
}