langref: atomic ops are allowed on pointers

Closes #6217
This commit is contained in:
Vexu 2020-09-04 21:41:34 +03:00
parent 88724b2a89
commit 6b2f4fd20d
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC
3 changed files with 8 additions and 8 deletions

View File

@ -6889,7 +6889,7 @@ fn func(y: *i32) void {
This builtin function atomically dereferences a pointer and returns the value.
</p>
<p>
{#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
{#header_close#}
@ -6899,7 +6899,7 @@ fn func(y: *i32) void {
This builtin function atomically modifies memory and then returns the previous value.
</p>
<p>
{#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
<p>
@ -6925,7 +6925,7 @@ fn func(y: *i32) void {
This builtin function atomically stores a value.
</p>
<p>
{#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
{#header_close#}
@ -7208,7 +7208,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
more efficiently in machine instructions.
</p>
<p>
{#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
<p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
@ -7237,7 +7237,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
However if you need a stronger guarantee, use {#link|@cmpxchgStrong#}.
</p>
<p>
{#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
<p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>

View File

@ -26752,7 +26752,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch
if (operand_type->id == ZigTypeIdFloat) {
ir_add_error(ira, &instruction->type_value->child->base,
buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name)));
buf_sprintf("expected bool, integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name)));
return ira->codegen->invalid_inst_gen;
}
@ -30407,7 +30407,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) {
return ira->codegen->builtin_types.entry_invalid;
if (operand_ptr_type == nullptr) {
ir_add_error(ira, &op->base,
buf_sprintf("expected integer, float, enum or pointer type, found '%s'",
buf_sprintf("expected bool, integer, float, enum or pointer type, found '%s'",
buf_ptr(&operand_type->name)));
return ira->codegen->builtin_types.entry_invalid;
}

View File

@ -899,7 +899,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst);
\\}
, &[_][]const u8{
"tmp.zig:3:22: error: expected integer, enum or pointer type, found 'f32'",
"tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32'",
});
cases.add("atomicrmw with float op not .Xchg, .Add or .Sub",