aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorVladPavliuk <pavliuk.vlad@gmail.com>2024-07-14 18:22:20 +0300
committerVladPavliuk <pavliuk.vlad@gmail.com>2024-07-14 18:22:20 +0300
commit3f8712edb03390c1eed4dced27f7c2707cf14ecb (patch)
treea186834d911e19418836bf2ca3f52f334c11267a /src/check_expr.cpp
parent79e2f63182581547dcdb7593397d1c3e280a5670 (diff)
parente7d37607ef9ce54a80d83230150874b71d628d6d (diff)
Merge branch 'master' into json-add-int-key-map-support
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 12acca0cb..82f64738f 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -6033,6 +6033,22 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
Entity *vt = pt->params->Tuple.variables[pt->variadic_index];
o.type = vt->type;
+
+ // NOTE(bill, 2024-07-14): minimize the stack usage for variadic parameters with the backing array
+ if (c->decl) {
+ bool found = false;
+ for (auto &vr : c->decl->variadic_reuses) {
+ if (are_types_identical(vt->type, vr.slice_type)) {
+ vr.max_count = gb_max(vr.max_count, variadic_operands.count);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ array_add(&c->decl->variadic_reuses, VariadicReuseData{vt->type, variadic_operands.count});
+ }
+ }
+
} else {
dummy_argument_count += 1;
o.type = t_untyped_nil;
@@ -7888,12 +7904,15 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
// NOTE: Due to restrictions in LLVM you can not inline calls with a superset of features.
if (is_call_inlined) {
- GB_ASSERT(c->curr_proc_decl);
- GB_ASSERT(c->curr_proc_decl->entity);
- GB_ASSERT(c->curr_proc_decl->entity->type->kind == Type_Proc);
- String scope_features = c->curr_proc_decl->entity->type->Proc.enable_target_feature;
- if (!check_target_feature_is_superset_of(scope_features, pt->Proc.enable_target_feature, &invalid)) {
- error(call, "Inlined procedure enables target feature '%.*s', this requires the calling procedure to at least enable the same feature", LIT(invalid));
+ if (c->curr_proc_decl == nullptr) {
+ error(call, "Calling a '#force_inline' procedure that enables target features is not allowed at file scope");
+ } else {
+ GB_ASSERT(c->curr_proc_decl->entity);
+ GB_ASSERT(c->curr_proc_decl->entity->type->kind == Type_Proc);
+ String scope_features = c->curr_proc_decl->entity->type->Proc.enable_target_feature;
+ if (!check_target_feature_is_superset_of(scope_features, pt->Proc.enable_target_feature, &invalid)) {
+ error(call, "Inlined procedure enables target feature '%.*s', this requires the calling procedure to at least enable the same feature", LIT(invalid));
+ }
}
}
}