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...@@ -20860,6 +20860,12 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
20860 if (!ir_resolve_atomic_order(ira, order_value, &order))20860 if (!ir_resolve_atomic_order(ira, order_value, &order))
20861 return ira->codegen->invalid_instruction;20861 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
20863 IrInstruction *result = ir_build_fence(&ira->new_irb,20869 IrInstruction *result = ir_build_fence(&ira->new_irb,
20864 instruction->base.scope, instruction->base.source_node, order_value, order);20870 instruction->base.scope, instruction->base.source_node, order_value, order);
20865 result->value.type = ira->codegen->builtin_types.entry_void;20871 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 {...@@ -14,6 +14,15 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
14 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",14 "tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",
15 );15 );
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
17 cases.add(26 cases.add(
18 "bad alignment in implicit cast from array pointer to slice",27 "bad alignment in implicit cast from array pointer to slice",
19 \\export fn a() void {28 \\export fn a() void {