aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index aa8fe0d060..ee3235d342 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -1560,6 +1560,17 @@ static void preview_fn_proto_instance(CodeGen *g, ImportTableEntry *import, AstN
proto_node->data.fn_proto.fn_table_entry = fn_table_entry;
resolve_function_proto(g, proto_node, fn_table_entry, import, containing_context);
+
+ if (is_main_fn && !g->link_libc) {
+ TypeTableEntry *err_void = get_error_type(g, g->builtin_types.entry_void);
+ TypeTableEntry *actual_return_type = fn_table_entry->type_entry->data.fn.fn_type_id.return_type;
+ if (actual_return_type != err_void) {
+ AstNode *return_type_node = fn_table_entry->proto_node->data.fn_proto.return_type;
+ add_node_error(g, return_type_node,
+ buf_sprintf("expected return type of main to be '%%void', instead is '%s'",
+ buf_ptr(&actual_return_type->name)));
+ }
+ }
}
static void preview_fn_proto(CodeGen *g, ImportTableEntry *import, AstNode *proto_node) {