@@ -1,4 +1,3 @@
-{$mode objfpc}
uses
Math;
@@ -642,10 +641,70 @@ procedure TestLongint;
TestFail(338);
end;
+ var
+ v1,v3 : Longint;
+
+ function Min1: Longint; inline;
+ begin
+ if v1 < v3 then
+ Result := v1
+ else
+ Result := v3;
+ end;
+ function Max1: Longint; inline;
+ if v1 > v3 then
+var
+ c1 : Longint = 1;
+ c3 : Longint = 3;
+ function Min11: Longint; inline;
+ if c1 < c3 then
+ Result := c1
+ Result := c3;
+ function Max11: Longint; inline;
+ if c1 > c3 then
+procedure TestLongintGlobal;
+ v1:=1;
+ v3:=3;
+ if Min1<>1 then
+ TestFail(1301);
+ if Max1<>3 then
+ TestFail(1302);
+ if Min11<>1 then
+ TestFail(1311);
+ if Max11<>3 then
+ TestFail(1312);
begin
TestSingle;
TestDouble;
TestDWord;
TestLongint;
+ TestLongintGlobal;
WriteLn('ok');
end.
@@ -1,2 +1,4 @@
{ %opt=-O- -O1 } { ensure we test code generation without constant propagation }
+{$mode objfpc}
{$I minmax.inc }
@@ -1,3 +1,5 @@
{ %opt=-Oonofastmath -O3 } { with fast math, the operands of min/max might be swapped and this breaks the tests using NaN,
but test constant propagation and thus simplification }