aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-06-28 20:50:14 +0300
committerJakub Konka <kubkon@jakubkonka.com>2022-06-30 09:57:38 +0200
commitcc3336c7841c48622db855be95a79bbd030bade8 (patch)
tree61e33f1add4655dcc28a25c239d5da27477be0e6 /src/AstGen.zig
parent979910dc38cd15e506218d5175e5a91f56244055 (diff)
downloadzig-cc3336c7841c48622db855be95a79bbd030bade8.tar.gz
zig-cc3336c7841c48622db855be95a79bbd030bade8.zip
Sema: add source location to coerce result ptr, fix negation error
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig9
1 files changed, 5 insertions, 4 deletions
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;