Odin_Calling_Convention defined in compiler; Allow for main :: proc "contextless" () {} with -bedrock; intrinsics.type_proc_calling_convention

This commit is contained in:
gingerBill
2026-05-05 15:07:42 +01:00
parent 942c1bff17
commit 8ffcdf172a
10 changed files with 101 additions and 20 deletions

View File

@@ -1527,10 +1527,26 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
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");
if (build_context.bedrock) {
switch (pt->calling_convention) {
case ProcCC_Odin:
case ProcCC_Contextless:
// Okay
break;
default:
error(e->token, "Procedure 'main' cannot have a custom calling convention beyond \"odin\" and \"contextless\" with '-bedrock'");
pt->calling_convention = ProcCC_Odin;
break;
}
} else {
if (pt->calling_convention != default_calling_convention()) {
error(e->token, "Procedure 'main' cannot have a custom calling convention");
}
pt->calling_convention = default_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'");