diff options
| author | gingerBill <bill@gingerbill.org> | 2025-06-09 17:19:58 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2025-06-09 17:19:58 +0100 |
| commit | 002b50360c7fd9a5ac62816e634c1bd73277f90d (patch) | |
| tree | 3437f8efab2ee300bdf9fffe17aead4365e21336 /src/llvm_backend_const.cpp | |
| parent | 2ffd6be20a50f1f9146af3c12c5adf8cf3d2e095 (diff) | |
| parent | 4a675395c5c65199046b5aefbe8528f5969d633e (diff) | |
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'src/llvm_backend_const.cpp')
| -rw-r--r-- | src/llvm_backend_const.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index 02bb7473c..e897ae282 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -1056,7 +1056,18 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb res.value = lb_build_constant_array_values(m, type, elem_type, cast(isize)type->Array.count, values, cc); return res; + } else if (value.value_compound->tav.type == elem_type) { + // Compound is of array item type; expand its value to all items in array. + LLVMValueRef* values = gb_alloc_array(temporary_allocator(), LLVMValueRef, cast(isize)type->Array.count); + + for (isize i = 0; i < type->Array.count; i++) { + values[i] = lb_const_value(m, elem_type, value, cc).value; + } + + res.value = lb_build_constant_array_values(m, type, elem_type, cast(isize)type->Array.count, values, cc); + return res; } else { + // Assume that compound value is an array literal GB_ASSERT_MSG(elem_count == type->Array.count, "%td != %td", elem_count, type->Array.count); LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, cast(isize)type->Array.count); |