From b06e7983733578d783bc585e7b0fc95f401b2e8d Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Wed, 16 Oct 2013 01:17:27 -0700 Subject: [PATCH] Revert "Remove undefined behavior from parse_error()." Per my understanding this is not undefined behavior. No ABI depends on the called function reading variadic arguments, nor does any standard require it. So if this is crashing something else must be going on. This reverts commit 22d22f6aa883a6f48e9df0cd55254faa2cfc425e. --- parse_tree.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/parse_tree.cpp b/parse_tree.cpp index 3e0c52566..97421dab1 100644 --- a/parse_tree.cpp +++ b/parse_tree.cpp @@ -341,7 +341,6 @@ class parse_ll_t bool top_node_handle_terminal_types(parse_token_t token); void parse_error(const wchar_t *expected, parse_token_t token); - void parse_error(parse_token_t token); void parse_error(parse_token_t token, const wchar_t *format, ...); void append_error_callout(wcstring &error_message, parse_token_t token); @@ -552,25 +551,19 @@ void parse_ll_t::acquire_output(parse_node_tree_t *output, parse_error_list_t *e this->symbol_stack.clear(); } -void parse_ll_t::parse_error(parse_token_t token) -{ - this->fatal_errored = true; -} - void parse_ll_t::parse_error(parse_token_t token, const wchar_t *fmt, ...) { - parse_error(token); - - //this->dump_stack(); - parse_error_t err; - - va_list va; - va_start(va, fmt); - err.text = vformat_string(fmt, va); - va_end(va); - + this->fatal_errored = true; if (this->should_generate_error_messages) { + //this->dump_stack(); + parse_error_t err; + + va_list va; + va_start(va, fmt); + err.text = vformat_string(fmt, va); + va_end(va); + err.source_start = token.source_start; err.source_length = token.source_length; this->errors.push_back(err); @@ -737,7 +730,7 @@ void parse_ll_t::accept_tokens(parse_token_t token1, parse_token_t token2) } else { - this->parse_error(token1); + this->parse_error(token1, NULL); } // parse_error sets fatal_errored, which ends the loop }