fix result loc of cast not finding parent

master
Andrew Kelley 2019-11-07 14:46:48 -05:00
parent e0db54e89d
commit fa34dfcce7
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
3 changed files with 8 additions and 8 deletions

View File

@ -15733,7 +15733,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
casted_value = nullptr;
}
if (casted_value == nullptr || type_is_invalid(casted_value->value.type)) {
if (casted_value != nullptr && type_is_invalid(casted_value->value.type)) {
return casted_value;
}

View File

@ -1,5 +1,5 @@
comptime {
//_ = @import("behavior/align.zig");
_ = @import("behavior/align.zig");
_ = @import("behavior/alignof.zig");
//_ = @import("behavior/array.zig");
_ = @import("behavior/asm.zig");
@ -73,7 +73,7 @@ comptime {
_ = @import("behavior/ir_block_deps.zig");
_ = @import("behavior/math.zig");
_ = @import("behavior/merge_error_sets.zig");
//_ = @import("behavior/misc.zig");
_ = @import("behavior/misc.zig");
_ = @import("behavior/muladd.zig");
_ = @import("behavior/namespace_depends_on_compile_var.zig");
_ = @import("behavior/new_stack_call.zig");

View File

@ -241,14 +241,14 @@ fn memFree(comptime T: type, memory: []T) void {}
test "cast undefined" {
const array: [100]u8 = undefined;
const slice = ([]const u8)(array);
const slice = @as([]const u8, array);
testCastUndefined(slice);
}
fn testCastUndefined(x: []const u8) void {}
test "cast small unsigned to larger signed" {
expect(castSmallUnsignedToLargerSigned1(200) == i16(200));
expect(castSmallUnsignedToLargerSigned2(9999) == i64(9999));
expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200));
expect(castSmallUnsignedToLargerSigned2(9999) == @as(i64, 9999));
}
fn castSmallUnsignedToLargerSigned1(x: u8) i16 {
return x;
@ -350,7 +350,7 @@ fn testTakeAddressOfParameter(f: f32) void {
}
test "pointer comparison" {
const a = ([]const u8)("a");
const a = @as([]const u8, "a");
const b = &a;
expect(ptrEql(b, b));
}
@ -642,7 +642,7 @@ test "self reference through fn ptr field" {
test "volatile load and store" {
var number: i32 = 1234;
const ptr = (*volatile i32)(&number);
const ptr = @as(*volatile i32, &number);
ptr.* += 1;
expect(ptr.* == 1235);
}