From f661d3404952d33d4cb683899ebd05d4b580b2bc Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 14 May 2020 00:13:26 +0100 Subject: Implement Explicit context creation #639 --- src/check_type.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/check_type.cpp') diff --git a/src/check_type.cpp b/src/check_type.cpp index 976c945fd..8d8bae1a7 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2501,6 +2501,19 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, c->curr_proc_sig = type; c->in_proc_sig = true; + + ProcCallingConvention cc = pt->calling_convention; + if (cc == ProcCC_ForeignBlockDefault) { + cc = ProcCC_CDecl; + if (c->foreign_context.default_cc > 0) { + cc = c->foreign_context.default_cc; + } + } + GB_ASSERT(cc > 0); + if (cc == ProcCC_Odin) { + c->scope->flags |= ScopeFlag_ContextDefined; + } + bool variadic = false; isize variadic_index = -1; bool success = true; @@ -2534,14 +2547,7 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, } - ProcCallingConvention cc = pt->calling_convention; - if (cc == ProcCC_ForeignBlockDefault) { - cc = ProcCC_CDecl; - if (c->foreign_context.default_cc > 0) { - cc = c->foreign_context.default_cc; - } - } - GB_ASSERT(cc > 0); + bool optional_ok = (pt->tags & ProcTag_optional_ok) != 0; if (optional_ok) { -- cgit v1.2.3