From f7b035a505e86ad916a43ab1dc1a662a6066b011 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 24 Sep 2026 00:39:51 +0200 Subject: Move module heading to the top --- gcc/gcc/elna-builtins.cc | 34 ++++++++++++++++++---------------- gcc/gcc/elna-generic.cc | 35 +++++++++++++++++------------------ gcc/gcc/elna-tree.cc | 5 +++-- 3 files changed, 38 insertions(+), 36 deletions(-) (limited to 'gcc') diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc index 0da991a..ee6856d 100644 --- a/gcc/gcc/elna-builtins.cc +++ b/gcc/gcc/elna-builtins.cc @@ -31,6 +31,7 @@ namespace elna::gcc { return boot::type_properties{ .size = static_cast(TYPE_PRECISION(node) / BITS_PER_UNIT), + // NOLINTNEXTLINE(bugprone-signed-bitwise) .alignment = TYPE_ALIGN_UNIT(node) }; } @@ -59,6 +60,7 @@ namespace elna::gcc .bool_properties = { .size = static_cast( (TYPE_PRECISION(elna_bool_type_node) + BITS_PER_UNIT - 1) / BITS_PER_UNIT), + // NOLINTNEXTLINE(bugprone-signed-bitwise) .alignment = TYPE_ALIGN_UNIT(elna_bool_type_node) }, .c_int_properties = get_host_numeric_properties(integer_type_node) @@ -190,14 +192,14 @@ namespace elna::gcc tree get_inner_alias(const boot::type& type, const std::shared_ptr& symbols, tree placeholder) { - if (auto reference = type.get()) + if (const auto reference = type.get()) { tree looked_up = symbols->lookup(reference->identifier); gcc_assert(looked_up != NULL_TREE); return TREE_TYPE(looked_up); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { tree composite_type_node = placeholder != NULL_TREE ? placeholder : make_node(RECORD_TYPE); @@ -220,11 +222,11 @@ namespace elna::gcc } return composite_type_node; } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { return build_enumeration_type(reference->members); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { /* * An incomplete type: a record without fields and without layout, @@ -233,17 +235,17 @@ namespace elna::gcc */ return make_node(RECORD_TYPE); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { return build_pointer_type(get_inner_alias(reference->base, symbols, placeholder)); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { tree base = get_inner_alias(reference->base, symbols, placeholder); return build_static_array_type(base, reference->size); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { tree base_type = get_inner_alias(reference->base, symbols, placeholder); tree slice_record = make_node(RECORD_TYPE); @@ -256,18 +258,18 @@ namespace elna::gcc layout_type(slice_record); return type_hash_canon(type_hash_canon_hash(slice_record), slice_record); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { tree procedure = build_procedure_type(*reference, symbols); return build_pointer_type(procedure); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { tree unqualified = get_inner_alias(reference->unqualified, symbols, placeholder); return build_qualified_type(unqualified, TYPE_QUAL_CONST); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { return TREE_TYPE(handle_symbol(reference->name, reference, symbols)); } @@ -275,13 +277,13 @@ namespace elna::gcc { return elna_pointer_type_node; } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { // Erasure is argument blind, so every instantiation of one generic // shares the tree the generic's own name is bound to. return get_inner_alias(reference->generic, symbols, placeholder); } - else if (auto reference = type.get()) + else if (const auto reference = type.get()) { return get_inner_alias(reference->referent, symbols, placeholder); } @@ -391,7 +393,7 @@ namespace elna::gcc const boot::type_info& info, const std::shared_ptr& symbols) { // The top level symbol table has basic (builtin) types in it which are not aliases. - if (auto alias_type = info.symbol.get()) + if (const auto alias_type = info.symbol.get()) { tree type_declaration = handle_symbol(name, alias_type, symbols); @@ -404,11 +406,11 @@ namespace elna::gcc { for (auto& [symbol_name, symbol_info] : *info_table) { - if (auto type_info = symbol_info->is_type()) + if (const auto type_info = symbol_info->is_type()) { declare_type(symbol_name, *type_info, symbols); } - else if (auto variable_info = symbol_info->is_variable()) + else if (const auto variable_info = symbol_info->is_variable()) { tree declaration_tree = declare_variable(symbol_name, *variable_info, symbols); @@ -422,7 +424,7 @@ namespace elna::gcc set_decl_tls_model(declaration_tree, decl_default_tls_model(declaration_tree)); } } - else if (auto procedure_info = symbol_info->is_procedure()) + else if (const auto procedure_info = symbol_info->is_procedure()) { declare_procedure(symbol_name, *procedure_info, symbols); } diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 46c8edc..034e4ae 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -106,6 +106,7 @@ namespace elna::gcc pointer.accept(this); tree pointee = get_inner_alias(accessed, this->symbols); + // NOLINTNEXTLINE(bugprone-signed-bitwise) tree qualified = build_qualified_type(pointee, TYPE_QUALS(pointee) | TYPE_QUAL_VOLATILE); tree address = fold_convert_loc(location, build_pointer_type(qualified), prepare_rvalue(this->current_expression)); @@ -200,10 +201,10 @@ namespace elna::gcc expression->value().accept(this); this->current_expression = prepare_rvalue(this->current_expression); const location_t cast_location = get_location(&expression->position()); - auto source_slice = resolve_underlying_type(expression->value().type_decoration) - .get(); - auto target_slice = resolve_underlying_type(expression->type_decoration) - .get(); + const std::shared_ptr source_slice = + resolve_underlying_type(expression->value().type_decoration).get(); + const std::shared_ptr target_slice = + resolve_underlying_type(expression->type_decoration).get(); if (source_slice != nullptr && target_slice != nullptr) { @@ -398,19 +399,13 @@ namespace elna::gcc declare_local_variable(unit->parameters.front(), argument_info, slice); } - for (boot::variable_declaration *const variable : unit->entry_point->variables) - { - variable->accept(this); - } - visit_statements(unit->entry_point->statements); + visit_statements(unit->entry_point.value()); - unit->entry_point->return_expression->accept(this); - tree return_value = fold_convert(integer_type_node, this->current_expression); - tree set_result = build2(INIT_EXPR, void_type_node, DECL_RESULT(fndecl), return_value); + tree set_result = build2(INIT_EXPR, void_type_node, DECL_RESULT(fndecl), integer_zero_node); tree return_stmt = build1(RETURN_EXPR, void_type_node, set_result); append_statement(return_stmt); - this->current_expression = NULL_TREE; + this->current_expression = NULL_TREE; this->bag.leave(); finish_function(fndecl); } @@ -428,7 +423,8 @@ namespace elna::gcc const std::string& variable_name = variable_identifier.name(); tree declaration_tree = this->symbols->lookup(variable_name); - auto variable_symbol = this->bag.lookup(variable_name)->is_variable(); + const std::shared_ptr variable_symbol = + this->bag.lookup(variable_name)->is_variable(); if (declaration_tree == NULL_TREE) { @@ -1080,9 +1076,11 @@ namespace elna::gcc tree end_pointer = do_pointer_arithmetic(boot::binary_operator::sum, start_pointer, length, location); enter_scope(); - // Declare control variable with the unqualified type. The constant_type wrapper - // is for semantic checking only, because GENERIC needs to modify the control variable. - auto control_variable_info = statement->body.symbols->lookup(statement->control_variable.name()); + // Declare control variable with the unqualified type. The constant_type + // wrapper is for semantic checking only, because GENERIC needs to modify + // the control variable. + const boot::symbol_table::symbol_ptr control_variable_info = + statement->body.symbols->lookup(statement->control_variable.name()); const boot::variable_info unqualified_info( boot::resolve_underlying_type(control_variable_info->is_variable()->symbol), control_variable_info->is_variable()->is_extern); @@ -1092,7 +1090,8 @@ namespace elna::gcc tree counter_declaration{ NULL_TREE }; if (statement->counter != nullptr) { - auto counter_info = statement->body.symbols->lookup(statement->counter->name()); + const boot::symbol_table::symbol_ptr counter_info = + statement->body.symbols->lookup(statement->counter->name()); counter_declaration = declare_local_variable(*statement->counter, *counter_info->is_variable(), elna_word_one_node); } diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc index 690cf41..e762b8e 100644 --- a/gcc/gcc/elna-tree.cc +++ b/gcc/gcc/elna-tree.cc @@ -226,6 +226,7 @@ namespace elna::gcc } TYPE_MIN_VALUE(composite_type_node) = DECL_INITIAL(TREE_VALUE(TYPE_VALUES(composite_type_node))); TYPE_UNSIGNED(composite_type_node) = TYPE_UNSIGNED(base_type); + // NOLINTNEXTLINE(bugprone-signed-bitwise) SET_TYPE_ALIGN(composite_type_node, TYPE_ALIGN(base_type)); TYPE_SIZE(composite_type_node) = NULL_TREE; TYPE_PRECISION(composite_type_node) = TYPE_PRECISION(base_type); @@ -261,7 +262,7 @@ namespace elna::gcc if (std::holds_alternative(constant_value)) { - auto literal_value = std::get(constant_value); + const boot::integer_literal literal_value = std::get(constant_value); if (literal_value.is_signed()) { @@ -282,7 +283,7 @@ namespace elna::gcc } else if (std::holds_alternative(constant_value)) { - auto literal = std::get(constant_value); + const boot::float_literal literal = std::get(constant_value); mpfr_t number; mpfr_init2(number, SIGNIFICAND_BITS); -- cgit v1.2.3