diff options
| author | gingerBill <bill@gingerbill.org> | 2021-09-13 01:14:17 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-09-13 01:14:17 +0100 |
| commit | 71bffd46dc9717ded66b3db353084871a11563e6 (patch) | |
| tree | 215c81ca6979427366dd66842530487c6dea008e /src/check_builtin.cpp | |
| parent | f5bc95eb349c75c8378a0a35104fd763db7742a1 (diff) | |
Reduce size of `Type`
Diffstat (limited to 'src/check_builtin.cpp')
| -rw-r--r-- | src/check_builtin.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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; |