From 470bfba45661d19558c0bf43b7819696a925ecb4 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 6 Jul 2026 10:44:15 +0200 Subject: Fix compiler crashing on syntax errors after error reporting. --- boot/semantic.cc | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'boot/semantic.cc') diff --git a/boot/semantic.cc b/boot/semantic.cc index 300c91d..29ef3c1 100644 --- a/boot/semantic.cc +++ b/boot/semantic.cc @@ -22,8 +22,8 @@ along with GCC; see the file COPYING3. If not see namespace elna::boot { - undeclared_error::undeclared_error(const std::string& identifier, const char *path, const struct position position) - : error(path, position), identifier(identifier) + undeclared_error::undeclared_error(const std::string& identifier, const struct position position) + : error(position), identifier(identifier) { } @@ -32,9 +32,8 @@ namespace elna::boot return "Type '" + identifier + "' not declared"; } - already_declared_error::already_declared_error(const std::string& identifier, - const char *path, const struct position position) - : error(path, position), identifier(identifier) + already_declared_error::already_declared_error(const std::string& identifier, const struct position position) + : error(position), identifier(identifier) { } @@ -43,9 +42,8 @@ namespace elna::boot return "Symbol '" + identifier + "' has been already declared"; } - field_duplication_error::field_duplication_error(const std::string& field_name, - const char *path, const struct position position) - : error(path, position), field_name(field_name) + field_duplication_error::field_duplication_error(const std::string& field_name, const struct position position) + : error(position), field_name(field_name) { } @@ -55,8 +53,8 @@ namespace elna::boot } cyclic_declaration_error::cyclic_declaration_error(const std::vector& cycle, - const char *path, const struct position position) - : error(path, position), cycle(cycle) + const struct position position) + : error(position), cycle(cycle) { } @@ -73,8 +71,8 @@ namespace elna::boot return message; } - return_error::return_error(const std::string& identifier, const char *path, const struct position position) - : error(path, position), identifier(identifier) + return_error::return_error(const std::string& identifier, const struct position position) + : error(position), identifier(identifier) { } @@ -83,8 +81,8 @@ namespace elna::boot return "Procedure '" + identifier + "' is expected to return, but does not have a return statement"; } - variable_initializer_error::variable_initializer_error(const char *path, const struct position position) - : error(path, position) + variable_initializer_error::variable_initializer_error(const struct position position) + : error(position) { } @@ -93,8 +91,8 @@ namespace elna::boot return "Only one variable can be initialized"; } - type_analysis_visitor::type_analysis_visitor(const char *path, symbol_bag bag) - : error_container(path), bag(bag) + type_analysis_visitor::type_analysis_visitor(symbol_bag bag) + : error_container(), bag(bag) { } @@ -113,7 +111,7 @@ namespace elna::boot } if (!this->returns) { - add_error(definition->identifier.name, this->input_file, definition->position()); + add_error(definition->identifier.name, definition->position()); } } } @@ -187,12 +185,12 @@ namespace elna::boot if (!check_unresolved_symbol(unresolved_type, alias_path)) { - add_error(alias_path, this->input_file, definition->position()); + add_error(alias_path, definition->position()); } } - name_analysis_visitor::name_analysis_visitor(const char *path, symbol_bag bag) - : error_container(path), bag(bag) + name_analysis_visitor::name_analysis_visitor(symbol_bag bag) + : error_container(), bag(bag) { } @@ -280,7 +278,7 @@ namespace elna::boot { if (field_names.find(field.first) != field_names.cend()) { - add_error(field.first, this->input_file, field.second->position()); + add_error(field.first, field.second->position()); } else { @@ -332,7 +330,7 @@ namespace elna::boot if (!this->bag.enter(name, variable_symbol)) { - add_error(name, this->input_file, position); + add_error(name, position); } return variable_symbol; } @@ -567,7 +565,7 @@ namespace elna::boot } else { - add_error(type_expression->name, this->input_file, type_expression->position()); + add_error(type_expression->name, type_expression->position()); this->current_type = type(); } } @@ -623,8 +621,8 @@ namespace elna::boot this->current_literal = literal->value; } - declaration_visitor::declaration_visitor(const char *path) - : error_container(path) + declaration_visitor::declaration_visitor() + : error_container() { } @@ -663,8 +661,7 @@ namespace elna::boot if (!this->unresolved.insert({ type_identifier, std::make_shared(type_identifier) }).second) { - add_error(definition->identifier.name, this->input_file, - definition->position()); + add_error(definition->identifier.name, definition->position()); } } @@ -672,7 +669,7 @@ namespace elna::boot { if (declaration->has_initializer() && declaration->identifiers.size() > 1) { - add_error(this->input_file, declaration->position()); + add_error(declaration->position()); } } -- cgit v1.2.3