aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-01-03 21:00:35 +0000
committergingerBill <bill@gingerbill.org>2024-01-03 21:00:35 +0000
commit70c5153471433bea6f3081ea3189613a02f54c6a (patch)
tree4e7ea9ddca89df9817a2f2d25863cb92e2f9292c /src/check_type.cpp
parentb410383aaf233f2d565a8601cc537b3bb158d064 (diff)
parent5961d4b31680aa4fc628b85fb49b6f936b3b925f (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index d66b196bc..f11418dc0 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -2070,33 +2070,33 @@ gb_internal bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc
type->Proc.diverging = pt->diverging;
type->Proc.optional_ok = optional_ok;
- if (param_count > 0) {
- Entity *end = params->Tuple.variables[param_count-1];
- if (end->flags&EntityFlag_CVarArg) {
+ bool is_polymorphic = false;
+ for (isize i = 0; i < param_count; i++) {
+ Entity *e = params->Tuple.variables[i];
+
+ if (e->kind != Entity_Variable) {
+ is_polymorphic = true;
+ } else if (is_type_polymorphic(e->type)) {
+ is_polymorphic = true;
+ }
+
+ if (e->flags&EntityFlag_CVarArg) {
+ if (i != param_count - 1) {
+ error(e->token, "#c_vararg can only be applied to the last parameter");
+ continue;
+ }
+
switch (cc) {
default:
type->Proc.c_vararg = true;
break;
case ProcCC_Odin:
case ProcCC_Contextless:
- error(end->token, "Calling convention does not support #c_vararg");
+ error(e->token, "Calling convention does not support #c_vararg");
break;
}
}
}
-
-
- bool is_polymorphic = false;
- for (isize i = 0; i < param_count; i++) {
- Entity *e = params->Tuple.variables[i];
- if (e->kind != Entity_Variable) {
- is_polymorphic = true;
- break;
- } else if (is_type_polymorphic(e->type)) {
- is_polymorphic = true;
- break;
- }
- }
for (isize i = 0; i < result_count; i++) {
Entity *e = results->Tuple.variables[i];
if (e->kind != Entity_Variable) {