zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fb8da16a60e13b09c5c6bb4989c204da536597b7 (tree)
parent d0b055d69e44848cf602a1ce8709ed568728a822
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 13 Jan 2020 12:16:35 -0500

fix regressions in get_elem_ptr related to undefined

Diffstat:
Msrc/ir.cpp | 8++++----
Mtest/stage1/behavior.zig | 4++--
Mtest/stage1/behavior/undefined.zig | 5+++--
3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/ir.cpp b/src/ir.cpp @@ -17918,6 +17918,9 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, var = var->next_var; } + if (var->var_type == nullptr || type_is_invalid(var->var_type)) + return ira->codegen->invalid_instruction; + bool is_volatile = false; ZigType *var_ptr_type = get_pointer_to_type_extra(ira->codegen, var->var_type, var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); @@ -17926,9 +17929,6 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, return ir_implicit_cast(ira, var->ptr_instruction, var_ptr_type); } - if (var->var_type == nullptr || type_is_invalid(var->var_type)) - return ira->codegen->invalid_instruction; - ZigValue *mem_slot = nullptr; bool comptime_var_mem = ir_get_var_is_comptime(var); @@ -19761,7 +19761,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) { if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, - elem_ptr_instruction->base.source_node, array_ptr_val, UndefBad))) + elem_ptr_instruction->base.source_node, array_ptr_val, UndefOk))) { return ira->codegen->invalid_instruction; } diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig @@ -66,7 +66,7 @@ comptime { _ = @import("behavior/fn.zig"); _ = @import("behavior/fn_in_struct_in_comptime.zig"); _ = @import("behavior/fn_delegation.zig"); - //_ = @import("behavior/for.zig"); + _ = @import("behavior/for.zig"); _ = @import("behavior/generics.zig"); _ = @import("behavior/hasdecl.zig"); _ = @import("behavior/hasfield.zig"); @@ -107,7 +107,7 @@ comptime { _ = @import("behavior/type.zig"); _ = @import("behavior/type_info.zig"); _ = @import("behavior/typename.zig"); - //_ = @import("behavior/undefined.zig"); + _ = @import("behavior/undefined.zig"); _ = @import("behavior/underscore.zig"); _ = @import("behavior/union.zig"); _ = @import("behavior/usingnamespace.zig"); diff --git a/test/stage1/behavior/undefined.zig b/test/stage1/behavior/undefined.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const mem = @import("std").mem; +const std = @import("std"); +const expect = std.testing.expect; +const mem = std.mem; fn initStaticArray() [10]i32 { var array: [10]i32 = undefined;