diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-09 21:41:19 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-09 21:41:19 +0100 |
| commit | c465171b457c2cd74595fbeeb0019cac3a63e5aa (patch) | |
| tree | f9645508c2ab96d2f8c2f20348635d08e32a362d /src | |
| parent | 02f22a0b3f27715d2906011c998263f07887894c (diff) | |
Fix #1061
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index a440c3540..99b804ea6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3860,10 +3860,29 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ } } + Type *original_type = operand->type; + Type *array_type = base_type(type_deref(original_type)); + GB_ASSERT(array_type->kind == Type_Array); + i64 array_count = array_type->Array.count; + for (u8 i = 0; i < index_count; i++) { + u8 idx = indices>>(i*2) & 3; + if (idx >= array_count) { + char c = 0; + if (found_xyzw) { + c = swizzles_xyzw[idx]; + } else if (found_rgba) { + c = swizzles_rgba[idx]; + } else { + GB_PANIC("unknown swizzle kind"); + } + error(selector->Ident.token, "Swizzle value is out of bounds, got %c, max count %lld", c, array_count); + break; + } + } + se->swizzle_count = index_count; se->swizzle_indices = indices; - Type *original_type = operand->type; AddressingMode prev_mode = operand->mode; operand->mode = Addressing_SwizzleValue; |