diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-05-13 13:08:54 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-05-13 13:08:54 -0700 |
| commit | 33e3d5645344d5c8076a1f020d49917334f6902a (patch) | |
| tree | cef7fac7e9eedd1c5004bdcf3aa02b0bacb9fb1c /src/analyze.cpp | |
| parent | 65e0e85685ac704088cc0ee319c6e4c51adb0c8b (diff) | |
| download | zig-33e3d5645344d5c8076a1f020d49917334f6902a.tar.gz zig-33e3d5645344d5c8076a1f020d49917334f6902a.zip | |
add error for wrong return type of main
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
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) { |
