authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-09-04 21:41:34+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-09-04 22:02:39+03:00
log6b2f4fd20d3c85e5db592f76dea8e56da54e9211
tree66751baec2774d8fbe428284bc1d01ad0d8a821c
parent88724b2a89157ecc3a8eea03aa0f8a6b66829915
signaturelock-open Commit is signed but in an unrecognized format.

langref: atomic ops are allowed on pointers

Closes #6217

3 files changed, 8 insertions(+), 8 deletions(-)

doc/langref.html.in+5-5
...@@ -6889,7 +6889,7 @@ fn func(y: *i32) void {...@@ -6889,7 +6889,7 @@ fn func(y: *i32) void {
6889 This builtin function atomically dereferences a pointer and returns the value.6889 This builtin function atomically dereferences a pointer and returns the value.
6890 </p>6890 </p>
6891 <p>6891 <p>
6892 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,6892 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
6893 an integer or an enum.6893 an integer or an enum.
6894 </p>6894 </p>
6895 {#header_close#}6895 {#header_close#}
...@@ -6899,7 +6899,7 @@ fn func(y: *i32) void {...@@ -6899,7 +6899,7 @@ fn func(y: *i32) void {
6899 This builtin function atomically modifies memory and then returns the previous value.6899 This builtin function atomically modifies memory and then returns the previous value.
6900 </p>6900 </p>
6901 <p>6901 <p>
6902 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,6902 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
6903 an integer or an enum.6903 an integer or an enum.
6904 </p>6904 </p>
6905 <p>6905 <p>
...@@ -6925,7 +6925,7 @@ fn func(y: *i32) void {...@@ -6925,7 +6925,7 @@ fn func(y: *i32) void {
6925 This builtin function atomically stores a value.6925 This builtin function atomically stores a value.
6926 </p>6926 </p>
6927 <p>6927 <p>
6928 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,6928 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
6929 an integer or an enum.6929 an integer or an enum.
6930 </p>6930 </p>
6931 {#header_close#}6931 {#header_close#}
...@@ -7208,7 +7208,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v...@@ -7208,7 +7208,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
7208 more efficiently in machine instructions.7208 more efficiently in machine instructions.
7209 </p>7209 </p>
7210 <p>7210 <p>
7211 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,7211 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
7212 an integer or an enum.7212 an integer or an enum.
7213 </p>7213 </p>
7214 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>7214 <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...@@ -7237,7 +7237,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
7237 However if you need a stronger guarantee, use {#link|@cmpxchgStrong#}.7237 However if you need a stronger guarantee, use {#link|@cmpxchgStrong#}.
7238 </p>7238 </p>
7239 <p>7239 <p>
7240 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,7240 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
7241 an integer or an enum.7241 an integer or an enum.
7242 </p>7242 </p>
7243 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>7243 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
src/ir.cpp+2-2
...@@ -26752,7 +26752,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch...@@ -26752,7 +26752,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch
2675226752
26753 if (operand_type->id == ZigTypeIdFloat) {26753 if (operand_type->id == ZigTypeIdFloat) {
26754 ir_add_error(ira, &instruction->type_value->child->base,26754 ir_add_error(ira, &instruction->type_value->child->base,
26755 buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name)));26755 buf_sprintf("expected bool, integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name)));
26756 return ira->codegen->invalid_inst_gen;26756 return ira->codegen->invalid_inst_gen;
26757 }26757 }
2675826758
...@@ -30407,7 +30407,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) {...@@ -30407,7 +30407,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) {
30407 return ira->codegen->builtin_types.entry_invalid;30407 return ira->codegen->builtin_types.entry_invalid;
30408 if (operand_ptr_type == nullptr) {30408 if (operand_ptr_type == nullptr) {
30409 ir_add_error(ira, &op->base,30409 ir_add_error(ira, &op->base,
30410 buf_sprintf("expected integer, float, enum or pointer type, found '%s'",30410 buf_sprintf("expected bool, integer, float, enum or pointer type, found '%s'",
30411 buf_ptr(&operand_type->name)));30411 buf_ptr(&operand_type->name)));
30412 return ira->codegen->builtin_types.entry_invalid;30412 return ira->codegen->builtin_types.entry_invalid;
30413 }30413 }
test/compile_errors.zig+1-1
...@@ -899,7 +899,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -899,7 +899,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
899 \\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst);899 \\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst);
900 \\}900 \\}
901 , &[_][]const u8{901 , &[_][]const u8{
902 "tmp.zig:3:22: error: expected integer, enum or pointer type, found 'f32'",902 "tmp.zig:3:22: error: expected bool, integer, enum or pointer type, found 'f32'",
903 });903 });
904904
905 cases.add("atomicrmw with float op not .Xchg, .Add or .Sub",905 cases.add("atomicrmw with float op not .Xchg, .Add or .Sub",