diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/gcc/elna-diagnostic.cc | 38 | ||||
| -rw-r--r-- | gcc/gcc/elna-generic.cc | 45 |
2 files changed, 39 insertions, 44 deletions
diff --git a/gcc/gcc/elna-diagnostic.cc b/gcc/gcc/elna-diagnostic.cc index f7b660d..3769ee4 100644 --- a/gcc/gcc/elna-diagnostic.cc +++ b/gcc/gcc/elna-diagnostic.cc @@ -38,27 +38,31 @@ namespace elna::gcc linemap_add(line_table, LC_LEAVE, 0, NULL, 0); } - location_t get_location(const boot::position *position) + location_t get_location(const boot::source_position *position) { - linemap_line_start(line_table, position->start.line, 0); + linemap_line_start(line_table, position->start().line(), 0); - return linemap_position_for_column(line_table, position->start.column); + return linemap_position_for_column(line_table, position->start().column()); } - void fill_range(const boot::position& position, location_t& start, location_t& end) + location_t make_range(const boot::source_position& position) { - linemap_line_start(line_table, position.start.line, 0); - start = linemap_position_for_column(line_table, position.start.column); + linemap_line_start(line_table, position.start().line(), 0); + location_t caret = linemap_position_for_column(line_table, position.start().column()); + location_t start = caret; + location_t end; - if (position.start.line != position.end.line || position.start.column != position.end.column) + if (position.is_span()) { - linemap_line_start(line_table, position.end.line, 0); - end = linemap_position_for_column(line_table, position.end.column); + linemap_line_start(line_table, position.end().line(), 0); + end = linemap_position_for_column(line_table, position.end().column()); } else { end = start; } + + return make_location(caret, start, end); } std::string print_aggregate_name(tree type, const std::string& kind_name) @@ -174,18 +178,20 @@ namespace elna::gcc { for (const auto& error : errors) { - if (error->position.start.available()) + if (error->position.start().available()) { - location_t start, end; - fill_range(error->position, start, end); - rich_location rich_loc(line_table, start); - rich_loc.add_range(end); - error_at(&rich_loc, error->what().c_str()); + location_t loc = make_range(error->position); + error_at(loc, "%s", error->what().c_str()); } else { location_t gcc_location{ UNKNOWN_LOCATION }; - error_at(gcc_location, error->what().c_str()); + error_at(gcc_location, "%s", error->what().c_str()); + } + if (auto note = error->note()) + { + location_t note_loc = make_range(note->second); + inform(note_loc, "%s", note->first.c_str()); } } } diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 18d31d6..aace38b 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -180,12 +180,10 @@ namespace elna::gcc void generic_visitor::visit(boot::record_constructor_expression *expression) { - tree type_decl = this->symbols->lookup(expression->type_name); + tree type_decl = this->symbols->lookup(expression->type_name.name()); if (type_decl == NULL_TREE) { - error_at(get_location(&expression->position()), "Type '%s' not declared", - expression->type_name.c_str()); this->current_expression = error_mark_node; return; } @@ -195,8 +193,8 @@ namespace elna::gcc for (const boot::field_initializer& initializer : expression->field_initializers) { tree field_decl = find_field_by_name(get_location(&expression->position()), - record_type, initializer.name); - initializer.value->accept(this); + record_type, initializer.name()); + initializer.value().accept(this); CONSTRUCTOR_APPEND_ELT(tree_arguments, field_decl, this->current_expression); } this->current_expression = build_constructor(record_type, tree_arguments); @@ -294,7 +292,7 @@ namespace elna::gcc void generic_visitor::visit(boot::procedure_declaration *declaration) { - tree fndecl = this->symbols->lookup(declaration->identifier.name); + tree fndecl = this->symbols->lookup(declaration->identifier.name()); if (!declaration->body.has_value()) { @@ -304,7 +302,7 @@ namespace elna::gcc DECL_STRUCT_FUNCTION(fndecl)->language = ggc_cleared_alloc<language_function>(); enter_scope(); - this->bag.enter(this->bag.lookup(declaration->identifier.name)->is_procedure()->scope); + this->bag.enter(this->bag.lookup(declaration->identifier.name())->is_procedure()->scope); tree argument_chain = DECL_ARGUMENTS(fndecl); for (; argument_chain != NULL_TREE; argument_chain = TREE_CHAIN(argument_chain)) @@ -712,15 +710,15 @@ namespace elna::gcc return; } tree definition_tree = build_decl(definition_location, CONST_DECL, - get_identifier(declaration->identifier.name.c_str()), TREE_TYPE(this->current_expression)); - auto result = this->symbols->enter(declaration->identifier.name, definition_tree); + get_identifier(declaration->identifier.name().c_str()), TREE_TYPE(this->current_expression)); + auto result = this->symbols->enter(declaration->identifier.name(), definition_tree); if (result) { DECL_INITIAL(definition_tree) = this->current_expression; TREE_CONSTANT(definition_tree) = 1; TREE_READONLY(definition_tree) = 1; - TREE_PUBLIC(definition_tree) = declaration->identifier.exported; + TREE_PUBLIC(definition_tree) = declaration->identifier.exported(); if (!lang_hooks.decls.global_bindings_p()) { @@ -729,11 +727,6 @@ namespace elna::gcc append_statement(declaration_statement); } } - else - { - error_at(definition_location, "Variable '%s' already declared in this scope", - declaration->identifier.name.c_str()); - } this->current_expression = NULL_TREE; } @@ -742,13 +735,13 @@ namespace elna::gcc for (const auto& variable_identifier : declaration->identifiers) { location_t declaration_location = get_location(&declaration->position()); - tree declaration_tree = this->symbols->lookup(variable_identifier.name); + tree declaration_tree = this->symbols->lookup(variable_identifier.name()); if (declaration_tree == NULL_TREE) { - auto variable_symbol = this->bag.lookup(variable_identifier.name)->is_variable(); + auto variable_symbol = this->bag.lookup(variable_identifier.name())->is_variable(); - declaration_tree = declare_variable(variable_identifier.name, *variable_symbol, this->symbols); + declaration_tree = declare_variable(variable_identifier.name(), *variable_symbol, this->symbols); } // Set initializer if given. if (declaration->initializer != nullptr) @@ -764,7 +757,7 @@ namespace elna::gcc if (lang_hooks.decls.global_bindings_p()) { - TREE_STATIC(declaration_tree) = !variable_identifier.exported && !declaration->is_extern; + TREE_STATIC(declaration_tree) = !variable_identifier.exported() && !declaration->is_extern; varpool_node::get_create(declaration_tree); varpool_node::finalize_decl(declaration_tree); } @@ -786,8 +779,6 @@ namespace elna::gcc if (symbol == NULL_TREE) { - error_at(get_location(&expression->position()), "Symbol '%s' not declared in the current scope", - expression->name.c_str()); this->current_expression = error_mark_node; } else @@ -843,7 +834,7 @@ namespace elna::gcc if (trait->arguments.size() != 1) { error_at(get_location(&trait->position()), "Trait '%s' expects 1 argument, got %lu", - trait->name.c_str(), trait->arguments.size()); + trait->name.name().c_str(), trait->arguments.size()); this->current_expression = error_mark_node; return false; } @@ -861,7 +852,7 @@ namespace elna::gcc else if (!is_integral_type(this->current_expression) && TREE_CODE(this->current_expression) != ENUMERAL_TYPE) { error_at(get_location(&trait->position()), "Type '%s' does not support trait '%s'", - print_type(this->current_expression).c_str(), trait->name.c_str()); + print_type(this->current_expression).c_str(), trait->name.name().c_str()); this->current_expression = error_mark_node; return false; } @@ -907,7 +898,7 @@ namespace elna::gcc if (trait->arguments.size() != 2) { error_at(trait_location, "Trait '%s' expects 2 arguments, got %lu", - trait->name.c_str(), trait->arguments.size()); + trait->name.name().c_str(), trait->arguments.size()); this->current_expression = error_mark_node; return; } @@ -936,7 +927,6 @@ namespace elna::gcc } else { - error_at(get_location(&trait->position()), "Trait '%s' is unknown", trait->name.c_str()); this->current_expression = error_mark_node; } } @@ -964,19 +954,18 @@ namespace elna::gcc for (iterator = TYPE_VALUES(aggregate_type); iterator != NULL_TREE; iterator = TREE_CHAIN(iterator)) { - if (IDENTIFIER_POINTER(TREE_PURPOSE(iterator)) == expression->field()) + if (IDENTIFIER_POINTER(TREE_PURPOSE(iterator)) == expression->field().name()) { this->current_expression = TREE_VALUE(iterator); return; } } this->current_expression = error_mark_node; - error_at(expression_location, "Unknown enumeration member '%s'", expression->field().c_str()); } else { tree field_declaration = find_field_by_name(expression_location, - TREE_TYPE(this->current_expression), expression->field()); + TREE_TYPE(this->current_expression), expression->field().name()); if (field_declaration != error_mark_node) { |
