From: Carl Worth Date: Wed, 11 Aug 2010 21:09:11 +0000 (-0700) Subject: glcpp: Fix "unterminated if" diagnostic. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da6b10a7eb26c8a13056cbae9015d5b84f134142;p=mesa.git glcpp: Fix "unterminated if" diagnostic. This was previously being appended to the output string *after* a copy of the supposedly final string was made and handed to the caller. So the diagnostic was never actually visible to the user. We fix this by moving the check for an unterminated #if from glcpp_parser_destroy to the calling function, preprocess. This fixes the test case 083-unterminated-if.c. --- diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index fe7549e5c5f..df26899a0f0 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -3333,8 +3333,6 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 0e0d9d412b6..7b08cd5807c 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1016,8 +1016,6 @@ glcpp_parser_parse (glcpp_parser_t *parser) void glcpp_parser_destroy (glcpp_parser_t *parser) { - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); glcpp_lex_destroy (parser->scanner); hash_table_dtor (parser->defines); talloc_free (parser); diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 3adccf72aab..52b6e96a65f 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -151,6 +151,9 @@ preprocess(void *talloc_ctx, const char **shader, char **info_log, glcpp_parser_parse (parser); + if (parser->skip_stack) + glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); + *info_log = talloc_strdup_append(*info_log, parser->info_log); talloc_steal(talloc_ctx, parser->output); diff --git a/src/glsl/glcpp/tests/083-unterminated-if.c.expected b/src/glsl/glcpp/tests/083-unterminated-if.c.expected new file mode 100644 index 00000000000..a69f8bab582 --- /dev/null +++ b/src/glsl/glcpp/tests/083-unterminated-if.c.expected @@ -0,0 +1,5 @@ +0:1(7): preprocessor error: Unterminated #if + + + +