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.
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);
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);
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);
--- /dev/null
+0:1(7): preprocessor error: Unterminated #if
+
+
+
+