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.
This commit is contained in:
Carl Worth
2010-08-11 14:09:11 -07:00
parent 6b9e7b034c
commit da6b10a7eb
4 changed files with 8 additions and 4 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -0,0 +1,5 @@
0:1(7): preprocessor error: Unterminated #if