aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-10-07 10:15:16 +0200
committerEugen Wissner <belka@caraus.de>2026-10-07 10:15:16 +0200
commitf547dae96d770cc7bc27d3790d0d87bb8e37963d (patch)
tree052abb2d81cabc5a3c5bde7d623ef2af9dcd45e9 /gcc
parentf9dfefc52fc792099b622ae47dafa32d2512e51e (diff)
downloadelna-f547dae96d770cc7bc27d3790d0d87bb8e37963d.tar.gz
Make procedure pointers compatible with normal pointers
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc/elna-builtins.cc4
-rw-r--r--gcc/gcc/elna-generic.cc18
-rw-r--r--gcc/gcc/elna-tree.cc12
3 files changed, 5 insertions, 29 deletions
diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc
index 643b988..56950e3 100644
--- a/gcc/gcc/elna-builtins.cc
+++ b/gcc/gcc/elna-builtins.cc
@@ -293,9 +293,7 @@ namespace elna::gcc
}
else if (const auto reference = type.get<boot::procedure_type>())
{
- tree procedure = build_procedure_type(*reference, symbols);
-
- return build_pointer_type(procedure);
+ return build_procedure_type(*reference, symbols);
}
else if (const auto reference = type.get<boot::constant_type>())
{
diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc
index fcc4c64..77ff61f 100644
--- a/gcc/gcc/elna-generic.cc
+++ b/gcc/gcc/elna-generic.cc
@@ -53,7 +53,6 @@ namespace elna::gcc
for (std::size_t i = 0; i < arguments.size(); ++i)
{
arguments.at(i)->accept(this);
- this->current_expression = prepare_rvalue(this->current_expression);
tree passed_type = get_inner_alias(argument_types.at(i), this->symbols);
const bool scalar_target = INTEGRAL_TYPE_P(passed_type)
@@ -108,8 +107,7 @@ namespace elna::gcc
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));
+ tree address = fold_convert_loc(location, build_pointer_type(qualified), this->current_expression);
tree reference = build_simple_mem_ref_loc(location, address);
TREE_THIS_VOLATILE(reference) = 1;
@@ -132,7 +130,7 @@ namespace elna::gcc
*call->arguments.at(0), call->argument_types.at(1));
call->arguments.at(1)->accept(this);
- tree value = prepare_rvalue(this->current_expression);
+ tree value = this->current_expression;
this->current_expression = build2_loc(call_location, MODIFY_EXPR, void_type_node,
target, value);
@@ -178,13 +176,7 @@ namespace elna::gcc
if (TREE_CODE(expression_type) == FUNCTION_TYPE)
{
- this->current_expression = build1(ADDR_EXPR,
- build_pointer_type(expression_type), this->current_expression);
- build_procedure_call(call_location, this->current_expression,
- call->arguments, call->argument_types);
- }
- else if (POINTER_TYPE_P(expression_type) && TREE_CODE(TREE_TYPE(expression_type)) == FUNCTION_TYPE)
- {
+ this->current_expression = build_fold_addr_expr_loc(call_location, this->current_expression);
build_procedure_call(call_location, this->current_expression,
call->arguments, call->argument_types);
}
@@ -199,7 +191,6 @@ namespace elna::gcc
tree cast_target = get_inner_alias(expression->type_decoration, this->symbols);
expression->value().accept(this);
- this->current_expression = prepare_rvalue(this->current_expression);
const location_t cast_location = get_location(&expression->position());
const std::shared_ptr<boot::slice_type> source_slice =
resolve_underlying_type(expression->value().type_decoration).get<boot::slice_type>();
@@ -825,7 +816,6 @@ namespace elna::gcc
{
TREE_ADDRESSABLE(this->current_expression) = 1;
}
- this->current_expression = prepare_rvalue(this->current_expression);
this->current_expression = build_fold_addr_expr_with_type_loc(location,
this->current_expression,
build_pointer_type(TREE_TYPE(this->current_expression)));
@@ -961,7 +951,7 @@ namespace elna::gcc
const location_t statement_location = get_location(&statement->position());
statement->rvalue().accept(this);
- tree rvalue = prepare_rvalue(this->current_expression);
+ tree rvalue = this->current_expression;
tree assignment = fold_build2_loc(statement_location, MODIFY_EXPR, void_type_node, lvalue, rvalue);
append_statement(assignment);
diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc
index e762b8e..b6384f8 100644
--- a/gcc/gcc/elna-tree.cc
+++ b/gcc/gcc/elna-tree.cc
@@ -38,18 +38,6 @@ namespace elna::gcc
return RECORD_OR_UNION_TYPE_P(type) || TREE_CODE(type) == ENUMERAL_TYPE;
}
- tree prepare_rvalue(tree rvalue)
- {
- if (DECL_P(rvalue) && TREE_CODE(TREE_TYPE(rvalue)) == FUNCTION_TYPE)
- {
- return build1(ADDR_EXPR, build_pointer_type(TREE_TYPE(rvalue)), rvalue);
- }
- else
- {
- return rvalue;
- }
- }
-
void append_statement(tree statement_tree)
{
if (!vec_safe_is_empty(f_binding_level->defers))