aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-01 09:30:39 +0200
committerEugen Wissner <belka@caraus.de>2026-08-01 09:34:21 +0200
commit8539c10542a4be1e1127daea60bf1b1e4c37e092 (patch)
treef04e3b0e97e4d201ee5ebdb0b2bd9079af4b1820 /gcc
parent661c29a7835cf1755deaf21f91832f00e958a318 (diff)
downloadelna-8539c10542a4be1e1127daea60bf1b1e4c37e092.tar.gz
Fix compile-time negation and array access
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc/elna-generic.cc8
-rw-r--r--gcc/gcc/elna-tree.cc18
2 files changed, 12 insertions, 14 deletions
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<std::int32_t> *literal)
- {
- this->current_expression = constant_to_tree(boot::constant_value{ literal->value }, this->symbols);
- }
-
void generic_visitor::visit(boot::literal<boot::integer_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<double> *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<symbol_table>& symbols, tree type)
{
- if (std::holds_alternative<std::int32_t>(constant_value))
+ if (std::holds_alternative<boot::integer_literal>(constant_value))
{
- return build_int_cst(elna_int_type_node, std::get<std::int32_t>(constant_value));
- }
- else if (std::holds_alternative<boot::integer_literal>(constant_value))
- {
- return build_int_cstu(elna_word_type_node,
- std::get<boot::integer_literal>(constant_value).to<std::uint32_t>());
+ auto literal_value = std::get<boot::integer_literal>(constant_value);
+
+ if (literal_value.is_signed())
+ {
+ return build_int_cst(elna_int_type_node, literal_value.to<std::int32_t>());
+ }
+ else
+ {
+ return build_int_cstu(elna_word_type_node, literal_value.to<std::uint32_t>());
+ }
}
else if (std::holds_alternative<double>(constant_value))
{