aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-01-12 19:18:54 +0000
committergingerBill <bill@gingerbill.org>2022-01-12 19:19:43 +0000
commit7e4067c44ceb21b4ca0ce89e501df1bf9de106b7 (patch)
treeab84472e0d084203d520cdcc93344e4d76ac9d56 /src/check_decl.cpp
parentf2f6c3c67d310c3ffce4c996b732d98f0abbe341 (diff)
Begin work to move entry point code to Odin itself rather than in C++ side
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 3f7d2f33d..f9bc17ba4 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -777,21 +777,23 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
if (e->pkg != nullptr && e->token.string == "main") {
- if (pt->param_count != 0 ||
- pt->result_count != 0) {
- gbString str = type_to_string(proc_type);
- error(e->token, "Procedure type of 'main' was expected to be 'proc()', got %s", str);
- gb_string_free(str);
- }
- if (pt->calling_convention != default_calling_convention()) {
- error(e->token, "Procedure 'main' cannot have a custom calling convention");
- }
- pt->calling_convention = default_calling_convention();
- if (e->pkg->kind == Package_Init) {
- if (ctx->info->entry_point != nullptr) {
- error(e->token, "Redeclaration of the entry pointer procedure 'main'");
- } else {
- ctx->info->entry_point = e;
+ if (e->pkg->kind != Package_Runtime) {
+ if (pt->param_count != 0 ||
+ pt->result_count != 0) {
+ gbString str = type_to_string(proc_type);
+ error(e->token, "Procedure type of 'main' was expected to be 'proc()', got %s", str);
+ gb_string_free(str);
+ }
+ if (pt->calling_convention != default_calling_convention()) {
+ error(e->token, "Procedure 'main' cannot have a custom calling convention");
+ }
+ pt->calling_convention = default_calling_convention();
+ if (e->pkg->kind == Package_Init) {
+ if (ctx->info->entry_point != nullptr) {
+ error(e->token, "Redeclaration of the entry pointer procedure 'main'");
+ } else {
+ ctx->info->entry_point = e;
+ }
}
}
}
@@ -924,7 +926,9 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
"\tother at %s",
LIT(name), token_pos_to_string(pos));
} else if (name == "main") {
- error(d->proc_lit, "The link name 'main' is reserved for internal use");
+ if (d->entity->pkg->kind != Package_Runtime) {
+ error(d->proc_lit, "The link name 'main' is reserved for internal use");
+ }
} else {
string_map_set(fp, key, e);
}