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 {
68896889 This builtin function atomically dereferences a pointer and returns the value.
68906890 </p>
68916891 <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,
68936893 an integer or an enum.
68946894 </p>
68956895 {#header_close#}
......@@ -6899,7 +6899,7 @@ fn func(y: *i32) void {
68996899 This builtin function atomically modifies memory and then returns the previous value.
69006900 </p>
69016901 <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,
69036903 an integer or an enum.
69046904 </p>
69056905 <p>
......@@ -6925,7 +6925,7 @@ fn func(y: *i32) void {
69256925 This builtin function atomically stores a value.
69266926 </p>
69276927 <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,
69296929 an integer or an enum.
69306930 </p>
69316931 {#header_close#}
......@@ -7208,7 +7208,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
72087208 more efficiently in machine instructions.
72097209 </p>
72107210 <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,
72127212 an integer or an enum.
72137213 </p>
72147214 <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
72377237 However if you need a stronger guarantee, use {#link|@cmpxchgStrong#}.
72387238 </p>
72397239 <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,
72417241 an integer or an enum.
72427242 </p>
72437243 <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
2675226752
2675326753 if (operand_type->id == ZigTypeIdFloat) {
2675426754 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)));
2675626756 return ira->codegen->invalid_inst_gen;
2675726757 }
2675826758
......@@ -30407,7 +30407,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) {
3040730407 return ira->codegen->builtin_types.entry_invalid;
3040830408 if (operand_ptr_type == nullptr) {
3040930409 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'",
3041130411 buf_ptr(&operand_type->name)));
3041230412 return ira->codegen->builtin_types.entry_invalid;
3041330413 }
test/compile_errors.zig+1-1
......@@ -899,7 +899,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
899899 \\ _ = @cmpxchgWeak(f32, &x, 1, 2, .SeqCst, .SeqCst);
900900 \\}
901901 , &[_][]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'",
903903 });
904904
905905 cases.add("atomicrmw with float op not .Xchg, .Add or .Sub",