authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-19 23:52:51-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-19 23:52:51-04:00
log3c541d7be38d625645276f8a0dee57774fe94134
treedddb742c68b4a1f1b59fad0629d2322b0edade3c
parent6217b401f94380a0a82aa979bc4ac90e7431267d
signature Commit is signed but in an unrecognized format.

fix peer result loc fn call with comptime condition


3 files changed, 23 insertions(+), 23 deletions(-)

src/ir.cpp+2-2
......@@ -16004,7 +16004,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1600416004 IrInstruction *result_loc;
1600516005 if (handle_is_ptr(impl_fn_type_id->return_type)) {
1600616006 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
16007 impl_fn_type_id->return_type, nullptr, true, false);
16007 impl_fn_type_id->return_type, nullptr, true, true);
1600816008 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
1600916009 return result_loc;
1601016010 }
......@@ -16124,7 +16124,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1612416124 IrInstruction *result_loc;
1612516125 if (handle_is_ptr(return_type)) {
1612616126 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
16127 return_type, nullptr, true, false);
16127 return_type, nullptr, true, true);
1612816128 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
1612916129 return result_loc;
1613016130 }
test/stage1/behavior.zig+1-1
......@@ -76,7 +76,7 @@ comptime {
7676 _ = @import("behavior/sizeof_and_typeof.zig");
7777 _ = @import("behavior/slice.zig");
7878 _ = @import("behavior/slicetobytes.zig");
79 _ = @import("behavior/struct.zig"); // TODO
79 _ = @import("behavior/struct.zig");
8080 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
8181 _ = @import("behavior/struct_contains_slice_of_itself.zig");
8282 _ = @import("behavior/switch.zig");
test/stage1/behavior/struct.zig+20-20
......@@ -529,26 +529,26 @@ test "access to global struct fields" {
529529 expect(g_foo.bar.value == 42);
530530}
531531
532//test "packed struct with fp fields" {
533// const S = packed struct {
534// data: [3]f32,
535//
536// pub fn frob(self: *@This()) void {
537// self.data[0] += self.data[1] + self.data[2];
538// self.data[1] += self.data[0] + self.data[2];
539// self.data[2] += self.data[0] + self.data[1];
540// }
541// };
542//
543// var s: S = undefined;
544// s.data[0] = 1.0;
545// s.data[1] = 2.0;
546// s.data[2] = 3.0;
547// s.frob();
548// expectEqual(f32(6.0), s.data[0]);
549// expectEqual(f32(11.0), s.data[1]);
550// expectEqual(f32(20.0), s.data[2]);
551//}
532test "packed struct with fp fields" {
533 const S = packed struct {
534 data: [3]f32,
535
536 pub fn frob(self: *@This()) void {
537 self.data[0] += self.data[1] + self.data[2];
538 self.data[1] += self.data[0] + self.data[2];
539 self.data[2] += self.data[0] + self.data[1];
540 }
541 };
542
543 var s: S = undefined;
544 s.data[0] = 1.0;
545 s.data[1] = 2.0;
546 s.data[2] = 3.0;
547 s.frob();
548 expectEqual(f32(6.0), s.data[0]);
549 expectEqual(f32(11.0), s.data[1]);
550 expectEqual(f32(20.0), s.data[2]);
551}
552552
553553test "use within struct scope" {
554554 const S = struct {