authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-08-17 22:51:25+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-17 16:05:41-04:00
log0ff396c34f93b60a000e1ee50e881a8c25122b79
tree6d135970e8f427cc43dc438a5b9b96a967c43264
parent4d8a6f6fea1b6922e7904b33c5b575249213fe53

add compile error for incorrect atomic ordering in fence #3082


2 files changed, 15 insertions(+), 0 deletions(-)

src/ir.cpp+6
......@@ -20860,6 +20860,12 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
2086020860 if (!ir_resolve_atomic_order(ira, order_value, &order))
2086120861 return ira->codegen->invalid_instruction;
2086220862
20863 if (order < AtomicOrderAcquire) {
20864 ir_add_error(ira, order_value,
20865 buf_sprintf("atomic ordering must be Acquire or stricter"));
20866 return ira->codegen->invalid_instruction;
20867 }
20868
2086320869 IrInstruction *result = ir_build_fence(&ira->new_irb,
2086420870 instruction->base.scope, instruction->base.source_node, order_value, order);
2086520871 result->value.type = ira->codegen->builtin_types.entry_void;
test/compile_errors.zig+9
......@@ -14,6 +14,15 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1414 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",
1515 );
1616
17 cases.add(
18 "atomic orderings of fence Acquire or stricter",
19 \\export fn entry() void {
20 \\ @fence(.Monotonic);
21 \\}
22 ,
23 "tmp.zig:2:12: error: atomic ordering must be Acquire or stricter",
24 );
25
1726 cases.add(
1827 "bad alignment in implicit cast from array pointer to slice",
1928 \\export fn a() void {