diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-19 15:58:31 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-19 15:58:31 -0400 |
| commit | d067a037cce906d600851e9b88df251451f9a93e (patch) | |
| tree | a56800c1e0da481102a8f846186744af8b1731e1 /src/ir.cpp | |
| parent | 44fb5275c1babed97a38b4b3c97e59740a2a5cc5 (diff) | |
| download | zig-d067a037cce906d600851e9b88df251451f9a93e.tar.gz zig-d067a037cce906d600851e9b88df251451f9a93e.zip | |
fix void array as a local variable initializer
Related: #1767
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 3b855b374f..ccdd34f893 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -13940,8 +13940,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * uint64_t old_array_len = array_type->data.array.len; uint64_t new_array_len; - if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) - { + if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) { ir_add_error(ira, &instruction->base, buf_sprintf("operation results in overflow")); return ira->codegen->invalid_instruction; } @@ -13956,6 +13955,15 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * return result; } + switch (type_has_one_possible_value(ira->codegen, result->value.type)) { + case OnePossibleValueInvalid: + return ira->codegen->invalid_instruction; + case OnePossibleValueYes: + return result; + case OnePossibleValueNo: + break; + } + // TODO optimize the buf case expand_undef_array(ira->codegen, array_val); out_val->data.x_array.data.s_none.elements = create_const_vals(new_array_len); |
