glcpp: Add an explicit diagnostic for #if with no expression.
authorCarl Worth <cworth@cworth.org>
Wed, 11 Aug 2010 20:59:22 +0000 (13:59 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 11 Aug 2010 21:38:04 +0000 (14:38 -0700)
This is more clear than the previously-generated diagnostic which was
something confusing like "enexpected newline".

This change makse test 080-if-witout-expression.c now pass.

src/glsl/glcpp/glcpp-parse.y
src/glsl/glcpp/tests/080-if-without-expression.c.expected

index 795030ecfe758ead5d2bbd540bff50897b013f1f..0e0d9d412b675aa3f41392d3f6ed6d2523e42acf 100644 (file)
@@ -241,6 +241,16 @@ control_line:
                        parser->skip_stack->type = SKIP_TO_ENDIF;
                }
        }
+|      HASH_IF NEWLINE {
+               /* #if without an expression is only an error if we
+                *  are not skipping */
+               if (parser->skip_stack == NULL ||
+                   parser->skip_stack->type == SKIP_NO_SKIP)
+               {
+                       glcpp_error(& @1, parser, "#if with no expression");
+               }       
+               _glcpp_parser_skip_stack_push_if (parser, & @1, 0);
+       }
 |      HASH_IFDEF IDENTIFIER junk NEWLINE {
                macro_t *macro = hash_table_find (parser->defines, $2);
                talloc_free ($2);
index 1a3e383e9adc3832f7a38c1840a3859c3fe5383f..768ba0f473f7c816eb644403a684aeba9bcff780 100644 (file)
@@ -1,3 +1,6 @@
 0:2(1): preprocessor error: #if with no expression
-
  
+
+
+
+