diff options
| author | gingerBill <bill@gingerbill.org> | 2017-10-29 18:09:05 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-10-29 18:09:05 +0000 |
| commit | 3e05be8eb8b14729b63ee541d11b3deb19b38710 (patch) | |
| tree | 938e806dc49e06fbed11bd1a1fe718b481a935f6 /src/check_type.cpp | |
| parent | ae24a8e5ae77111cae24cd8d710b63636b737283 (diff) | |
`@(default_calling_convention = ...)` for `foreign` blocks
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 95b876ef8..5d3382f47 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1888,6 +1888,15 @@ bool check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node, Array } } + ProcCallingConvention cc = pt->calling_convention; + if (cc == ProcCC_ForeignBlockDefault) { + cc = ProcCC_C; + if (c->context.default_foreign_cc > 0) { + cc = c->context.default_foreign_cc; + } + } + GB_ASSERT(cc > 0); + type->Proc.node = proc_type_node; type->Proc.scope = c->context.scope; type->Proc.params = params; @@ -1895,18 +1904,18 @@ bool check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node, Array type->Proc.results = results; type->Proc.result_count = cast(i32)result_count; type->Proc.variadic = variadic; - type->Proc.calling_convention = pt->calling_convention; + type->Proc.calling_convention = cc; type->Proc.is_polymorphic = pt->generic; type->Proc.specialization_count = specialization_count; if (param_count > 0) { Entity *end = params->Tuple.variables[param_count-1]; if (end->flags&EntityFlag_CVarArg) { - if (pt->calling_convention == ProcCC_Odin) { + if (cc == ProcCC_Odin) { error(end->token, "Odin calling convention does not support #c_vararg"); - } else if (pt->calling_convention == ProcCC_Contextless) { + } else if (cc == ProcCC_Contextless) { error(end->token, "Odin's contextless calling convention does not support #c_vararg"); - } else if (pt->calling_convention == ProcCC_Fast) { + } else if (cc == ProcCC_Fast) { error(end->token, "Fast calling convention does not support #c_vararg"); } else { type->Proc.c_vararg = true; |