From 71bffd46dc9717ded66b3db353084871a11563e6 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 13 Sep 2021 01:14:17 +0100 Subject: Reduce size of `Type` --- src/check_builtin.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/check_builtin.cpp') diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 1f9eea45d..4e8eed1fc 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1943,7 +1943,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 soa_struct->Struct.node = operand->expr; soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; - soa_struct->Struct.soa_count = count; + soa_struct->Struct.soa_count = cast(i32)count; scope = create_scope(c->info, c->scope); soa_struct->Struct.scope = scope; @@ -1976,7 +1976,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 soa_struct->Struct.node = operand->expr; soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; - soa_struct->Struct.soa_count = count; + if (count > I32_MAX) { + count = I32_MAX; + error(call, "Array count too large for an #soa struct, got %lld", cast(long long)count); + } + soa_struct->Struct.soa_count = cast(i32)count; scope = create_scope(c->info, old_struct->Struct.scope->parent); soa_struct->Struct.scope = scope; -- cgit v1.2.3