aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-05-25 21:17:21 +0100
committergingerBill <bill@gingerbill.org>2022-05-25 21:17:21 +0100
commit1549d01bf76e8c5e13626e57b1f976330a9cdd50 (patch)
treef57a02094dc02bed45d6d814b094a24b75939ae0 /src/check_type.cpp
parentb168bf9460491a101f3a7d41c28500a45898ecbf (diff)
Restrict `swizzle` to a power of two for #simd
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 1df63e599..088853810 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -2795,14 +2795,16 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
if (name == "soa") {
*type = make_soa_struct_fixed(ctx, e, at->elem, elem, count, generic_type);
} else if (name == "simd") {
- if (!is_type_valid_vector_elem(elem)) {
+ if (!is_type_valid_vector_elem(elem) && !is_type_polymorphic(elem)) {
gbString str = type_to_string(elem);
error(at->elem, "Invalid element type for 'intrinsics.simd_vector', expected an integer or float with no specific endianness, got '%s'", str);
gb_string_free(str);
*type = alloc_type_array(elem, count, generic_type);
goto array_end;
}
- if (count < 1 || !is_power_of_two(count)) {
+ if (is_type_polymorphic(elem)) {
+ count = 1;
+ } else if (count < 1 || !is_power_of_two(count)) {
error(at->count, "Invalid length for 'intrinsics.simd_vector', expected a power of two length, got '%lld'", cast(long long)count);
*type = alloc_type_array(elem, count, generic_type);
goto array_end;