From cc3336c7841c48622db855be95a79bbd030bade8 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 28 Jun 2022 20:50:14 +0300 Subject: Sema: add source location to coerce result ptr, fix negation error --- src/AstGen.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/AstGen.zig') diff --git a/src/AstGen.zig b/src/AstGen.zig index c4cba54bdc..c9abb1859b 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -1476,7 +1476,7 @@ fn arrayInitExprRlPtr( return arrayInitExprRlPtrInner(gz, scope, node, base_ptr, elements); } - var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr); + var as_scope = try gz.makeCoercionScope(scope, array_ty, result_ptr, node); defer as_scope.unstack(); const result = try arrayInitExprRlPtrInner(&as_scope, scope, node, as_scope.rl_ptr, elements); @@ -1697,7 +1697,7 @@ fn structInitExprRlPtr( const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); _ = try gz.addUnNode(.validate_struct_init_ty, ty_inst, node); - var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr); + var as_scope = try gz.makeCoercionScope(scope, ty_inst, result_ptr, node); defer as_scope.unstack(); const result = try structInitExprRlPtrInner(&as_scope, scope, node, struct_init, as_scope.rl_ptr); @@ -7046,7 +7046,7 @@ fn asRlPtr( operand_node: Ast.Node.Index, dest_type: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { - var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr); + var as_scope = try parent_gz.makeCoercionScope(scope, dest_type, result_ptr, src_node); defer as_scope.unstack(); const result = try reachableExpr(&as_scope, &as_scope.base, .{ .block_ptr = &as_scope }, operand_node, src_node); @@ -9903,13 +9903,14 @@ const GenZir = struct { scope: *Scope, dest_type: Zir.Inst.Ref, result_ptr: Zir.Inst.Ref, + src_node: Ast.Node.Index, ) !GenZir { // Detect whether this expr() call goes into rvalue() to store the result into the // result location. If it does, elide the coerce_result_ptr instruction // as well as the store instruction, instead passing the result as an rvalue. var as_scope = parent_gz.makeSubBlock(scope); errdefer as_scope.unstack(); - as_scope.rl_ptr = try as_scope.addBin(.coerce_result_ptr, dest_type, result_ptr); + as_scope.rl_ptr = try as_scope.addPlNode(.coerce_result_ptr, src_node, Zir.Inst.Bin{ .lhs = dest_type, .rhs = result_ptr }); // `rl_ty_inst` needs to be set in case the stores to `rl_ptr` are eliminated. as_scope.rl_ty_inst = dest_type; -- cgit v1.2.3