mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 16:24:51 +00:00
parent
44fb5275c1
commit
d067a037cc
12
src/ir.cpp
12
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);
|
||||
|
||||
@ -33,3 +33,8 @@ test "void optional" {
|
||||
var x: ?void = {};
|
||||
expect(x != null);
|
||||
}
|
||||
|
||||
test "void array as a local variable initializer" {
|
||||
var x = [_]void{{}} ** 1004;
|
||||
var y = x[0];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user