aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-16 12:42:46 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-16 12:42:46 -0500
commit4cbeb87e83135e0a1ecbfb90170761ad6e5adb7a (patch)
treeb95b6e7a7723280c7f9ae7be17ff748f4f2cfaa0 /src/ir.cpp
parentc7591736b4ae3aed90f6980b4cb23a4dab21d925 (diff)
downloadzig-4cbeb87e83135e0a1ecbfb90170761ad6e5adb7a.tar.gz
zig-4cbeb87e83135e0a1ecbfb90170761ad6e5adb7a.zip
fix handling of const values for 2d arrays
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 60c5f8b85c..98d56de989 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -8314,7 +8314,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_invalid;
bool safety_check_on = elem_ptr_instruction->safety_check_on;
- if (casted_elem_index->value.special != ConstValSpecialRuntime) {
+ if (instr_is_comptime(casted_elem_index)) {
uint64_t index = casted_elem_index->value.data.x_bignum.data.x_uint;
if (array_type->id == TypeTableEntryIdArray) {
uint64_t array_len = array_type->data.array.len;
@@ -9923,6 +9923,13 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
if (const_val.special == ConstValSpecialStatic) {
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, const_val.depends_on_compile_var);
*out_val = const_val;
+ for (size_t i = 0; i < elem_count; i += 1) {
+ ConstExprValue *elem_val = &out_val->data.x_array.elements[i];
+ if (elem_val->type->id == TypeTableEntryIdArray) {
+ elem_val->data.x_array.parent_array = out_val;
+ elem_val->data.x_array.parent_array_index = i;
+ }
+ }
return fixed_size_array_type;
}