From 8539c10542a4be1e1127daea60bf1b1e4c37e092 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 1 Aug 2026 09:30:39 +0200 Subject: Fix compile-time negation and array access --- gcc/gcc/elna-generic.cc | 8 +------- gcc/gcc/elna-tree.cc | 18 +++++++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'gcc') diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 6da3f99..969e929 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -478,15 +478,9 @@ namespace elna::gcc cgraph_node::finalize_function(fndecl, true); } - void generic_visitor::visit(boot::literal *literal) - { - this->current_expression = constant_to_tree(boot::constant_value{ literal->value }, this->symbols); - } - void generic_visitor::visit(boot::literal *literal) { - this->current_expression = constant_to_tree( - boot::constant_value{ literal->value }, this->symbols); + this->current_expression = constant_to_tree(boot::constant_value{ literal->value }, this->symbols); } void generic_visitor::visit(boot::literal *literal) diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc index 4b3ef81..55e359b 100644 --- a/gcc/gcc/elna-tree.cc +++ b/gcc/gcc/elna-tree.cc @@ -283,14 +283,18 @@ namespace elna::gcc tree constant_to_tree(const boot::constant_value& constant_value, const std::shared_ptr& symbols, tree type) { - if (std::holds_alternative(constant_value)) + if (std::holds_alternative(constant_value)) { - return build_int_cst(elna_int_type_node, std::get(constant_value)); - } - else if (std::holds_alternative(constant_value)) - { - return build_int_cstu(elna_word_type_node, - std::get(constant_value).to()); + auto literal_value = std::get(constant_value); + + if (literal_value.is_signed()) + { + return build_int_cst(elna_int_type_node, literal_value.to()); + } + else + { + return build_int_cstu(elna_word_type_node, literal_value.to()); + } } else if (std::holds_alternative(constant_value)) { -- cgit v1.2.3