From 311c023271a74374852431c0d9492cdf2749d4eb Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Fri, 13 Dec 2024 21:45:36 +0100 Subject: [PATCH] * ensure that any Boolean type can be used for the Succeeded parameter and that there are no unitialized warnings + added test --- compiler/ninl.pas | 5 +++-- tests/test/tatomic8.pp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/test/tatomic8.pp diff --git a/compiler/ninl.pas b/compiler/ninl.pas index 1a3fa51a22..3d6ca1ee09 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -4284,8 +4284,9 @@ implementation begin { the boolean parameter must be assignable } valid_for_var(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left,true); - set_varstate(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left,vs_readwritten,[vsf_must_be_valid]); - inserttypeconv(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left,pasbool1type); + set_varstate(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left,vs_written,[]); + if not is_boolean(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left.resultdef) then + inserttypeconv(tcallparanode(tcallparanode(tcallparanode(tcallparanode(left).right).right).right).left,pasbool1type); end; end; end; diff --git a/tests/test/tatomic8.pp b/tests/test/tatomic8.pp new file mode 100644 index 0000000000..c95123c254 --- /dev/null +++ b/tests/test/tatomic8.pp @@ -0,0 +1,34 @@ +{ %NORUN } + +program tatomic8; + +{$mode objfpc} + +procedure AvoidHint(aArg: array of Boolean); +begin +end; + +var + l: LongInt; + b: Boolean; + bb: ByteBool; + wb: WordBool; + lb: LongBool; + qb: QWordBool; + b8: Boolean8; + b16: Boolean16; + b32: Boolean32; + b64: Boolean64; +begin + l := 0; + AtomicCmpExchange(l, 42, 84, b); + AtomicCmpExchange(l, 42, 84, bb); + AtomicCmpExchange(l, 42, 84, wb); + AtomicCmpExchange(l, 42, 84, lb); + AtomicCmpExchange(l, 42, 84, qb); + AtomicCmpExchange(l, 42, 84, b8); + AtomicCmpExchange(l, 42, 84, b16); + AtomicCmpExchange(l, 42, 84, b32); + AtomicCmpExchange(l, 42, 84, b64); + AvoidHint([b, bb, wb, lb, qb, b8, b16, b32, b64]); +end.