Don't append return to void procedures

This commit is contained in:
Eugen Wissner 2025-01-13 11:55:19 +01:00
parent b45b00a3f6
commit daed398644
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0

View File

@ -160,16 +160,13 @@ namespace gcc
this->symbol_map->enter(definition->identifier(), source::make_info(this->main_fndecl));
tree resdecl = build_decl(UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, integer_type_node);
tree resdecl = build_decl(UNKNOWN_LOCATION, RESULT_DECL,
NULL_TREE, TREE_TYPE(TREE_TYPE(this->main_fndecl)));
DECL_CONTEXT(resdecl) = this->main_fndecl;
DECL_RESULT(this->main_fndecl) = resdecl;
tree set_result = build2(INIT_EXPR, void_type_node, DECL_RESULT(main_fndecl),
build_int_cst_type(integer_type_node, 0));
tree return_stmt = build1(RETURN_EXPR, void_type_node, set_result);
enter_scope();
definition->body().accept(this);
append_to_statement_list(return_stmt, &this->current_statements);
tree_symbol_mapping mapping = leave_scope();