From 0e3ca4c63ecb8e43af8261020d21bc6888d18fc0 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Thu, 25 Jul 2019 11:11:37 -0500 Subject: Fix array->vector and vector->array for many types. Allow vector of bool. Vectors do not have the same packing as arrays, and just bitcasting is not the correct way to convert them. --- src/analyze.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index d5d8745018..ac70d5646f 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4708,6 +4708,7 @@ ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) { bool is_valid_vector_elem_type(ZigType *elem_type) { return elem_type->id == ZigTypeIdInt || elem_type->id == ZigTypeIdFloat || + elem_type->id == ZigTypeIdBool || get_codegen_ptr_type(elem_type) != nullptr; } @@ -4727,7 +4728,7 @@ ZigType *get_vector_type(CodeGen *g, uint32_t len, ZigType *elem_type) { ZigType *entry = new_type_table_entry(ZigTypeIdVector); if ((len != 0) && type_has_bits(elem_type)) { - // Vectors can only be ints, floats, or pointers. ints and floats have trivially resolvable + // Vectors can only be ints, floats, bools, or pointers. ints (inc. bools) and floats have trivially resolvable // llvm type refs. pointers we will use usize instead. LLVMTypeRef example_vector_llvm_type; if (elem_type->id == ZigTypeIdPointer) { -- cgit v1.2.3