Ver Fonte

* ensure that any Boolean type can be used for the Succeeded parameter and that there are no unitialized warnings
+ added test

Sven/Sarah Barth há 8 meses atrás
pai
commit
311c023271
2 ficheiros alterados com 37 adições e 2 exclusões
  1. 3 2
      compiler/ninl.pas
  2. 34 0
      tests/test/tatomic8.pp

+ 3 - 2
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;

+ 34 - 0
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.