Implement procedure pointers

This commit is contained in:
2025-02-24 00:24:36 +01:00
parent 18857e1a88
commit 85b6843ecf
9 changed files with 217 additions and 181 deletions

View File

@ -51,12 +51,6 @@ namespace gcc
return TREE_CODE(type) == ARRAY_TYPE;
}
bool is_procedure_type(tree type)
{
gcc_assert(TYPE_P(type));
return TREE_CODE(type) == FUNCTION_TYPE;
}
bool is_void_type(tree type)
{
return type == NULL_TREE || type == void_type_node;
@ -77,6 +71,18 @@ namespace gcc
|| (is_pointer_type(lhs_type) && lhs_type == rhs_type);
}
tree prepare_rvalue(tree rvalue)
{
if (DECL_P(rvalue) && TREE_CODE(TREE_TYPE(rvalue)) == FUNCTION_TYPE)
{
return build1(ADDR_EXPR, build_pointer_type_for_mode(TREE_TYPE(rvalue), VOIDmode, true), rvalue);
}
else
{
return rvalue;
}
}
bool is_assignable_from(tree assignee, tree assignment)
{
return get_qualified_type(TREE_TYPE(assignment), TYPE_UNQUALIFIED) == assignee