diff options
| author | Shawn Landden <shawn@git.icu> | 2019-07-25 11:11:37 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-18 09:52:58 -0400 |
| commit | 0e3ca4c63ecb8e43af8261020d21bc6888d18fc0 (patch) | |
| tree | 7df095fa7a25c68d3648a3d87eaa937ce3ead5a4 /src/analyze.cpp | |
| parent | 914ad1ec2eff4ea9061804ad0da9cde7dd6543b6 (diff) | |
| download | zig-0e3ca4c63ecb8e43af8261020d21bc6888d18fc0.tar.gz zig-0e3ca4c63ecb8e43af8261020d21bc6888d18fc0.zip | |
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.
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
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) { |
