mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
AstGen: require binary operations to have reachable operands
This commit is contained in:
parent
b613210140
commit
d3426ce634
@ -4781,8 +4781,8 @@ fn simpleBinOp(
|
||||
const node_datas = tree.nodes.items(.data);
|
||||
|
||||
const result = try gz.addPlNode(op_inst_tag, node, Zir.Inst.Bin{
|
||||
.lhs = try expr(gz, scope, .none, node_datas[node].lhs),
|
||||
.rhs = try expr(gz, scope, .none, node_datas[node].rhs),
|
||||
.lhs = try reachableExpr(gz, scope, .none, node_datas[node].lhs, node),
|
||||
.rhs = try reachableExpr(gz, scope, .none, node_datas[node].rhs, node),
|
||||
});
|
||||
return rvalue(gz, rl, result, node);
|
||||
}
|
||||
|
@ -5033,13 +5033,18 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
"tmp.zig:2:5: note: control flow is diverted here",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("unreachable code - return return",
|
||||
ctx.objErrStage1("unreachable code - multiple things",
|
||||
\\export fn a() i32 {
|
||||
\\ return return 1;
|
||||
\\}
|
||||
\\export fn b(value: u32) bool {
|
||||
\\ return 1 < value < 1000;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:5: error: unreachable code",
|
||||
"tmp.zig:2:12: note: control flow is diverted here",
|
||||
"tmp.zig:5:22: error: unreachable code",
|
||||
"tmp.zig:5:5: note: control flow is diverted here",
|
||||
});
|
||||
|
||||
ctx.objErrStage1("bad import",
|
||||
|
Loading…
Reference in New Issue
Block a user