* more overloads for Math.Min/Max, resolves #36161

git-svn-id: trunk@43366 -
This commit is contained in:
florian 2019-11-02 16:21:43 +00:00
parent faee789507
commit 5ead23513d
3 changed files with 78 additions and 0 deletions

1
.gitattributes vendored
View File

@ -17849,6 +17849,7 @@ tests/webtbs/tw36013.pp svneol=native#text/pascal
tests/webtbs/tw3612.pp svneol=native#text/plain
tests/webtbs/tw36156.pp svneol=native#text/plain
tests/webtbs/tw36157.pp svneol=native#text/plain
tests/webtbs/tw36161.pp svneol=native#text/pascal
tests/webtbs/tw3617.pp svneol=native#text/plain
tests/webtbs/tw3619.pp svneol=native#text/plain
tests/webtbs/tw36196.pp svneol=native#text/pascal

View File

@ -167,6 +167,10 @@ function Min(a, b: Int64): Int64;inline; overload;
function Max(a, b: Int64): Int64;inline; overload;
function Min(a, b: QWord): QWord;inline; overload;
function Max(a, b: QWord): QWord;inline; overload;
function Min(a: Int64; b: Qword): Int64;inline; overload;
function Min(a: Qword; b: Int64): Int64;inline; overload;
function Max(a: Int64; b: Qword): QWord;inline; overload;
function Max(a: Qword; b: Int64): QWord;inline; overload;
{$ifdef FPC_HAS_TYPE_SINGLE}
function Min(a, b: Single): Single;inline; overload;
function Max(a, b: Single): Single;inline; overload;
@ -2075,6 +2079,39 @@ begin
end;
{$ifdef FPC_HAS_TYPE_SINGLE}
function Min(a: Int64; b: Qword): Int64;inline;
begin
if a<0 then
Result:=a
else
Result:=Min(QWord(a),b);
end;
function Min(a: Qword; b: Int64): Int64;inline;
begin
if b<0 then
Result:=b
else
Result:=Min(a,QWord(b));
end;
function Max(a: Int64; b: Qword): QWord;inline;
begin
if a<0 then
Result:=b
else
Result:=Max(QWord(a),b);
end;
function Max(a: Qword; b: Int64): QWord;inline;
begin
if b<0 then
Result:=a
else
Result:=Max(a,QWord(b));
end;
function Min(a, b: Single): Single;inline;
begin
if a < b then

40
tests/webtbs/tw36161.pp Normal file
View File

@ -0,0 +1,40 @@
{ %OPT=-O1 }
program Project1;
uses Math;
var
t: Qword;
i: int64;
begin
i:=-12345687;
t:=QWord($a000000000000000);
if Min(sizeof(t), t)<>sizeof(t) then
halt(1);
if Min(t, sizeof(t))<>sizeof(t) then
halt(2);
if Min(t, i)<>i then
halt(3);
if Min(i, t)<>i then
halt(4);
if Min(sizeof(t),sizeof(t))<>sizeof(t) then
halt(5);
if Min(t,t)<>t then
halt(6);
if Min(i,i)<>i then
halt(7);
if Max(sizeof(t), t)<>t then
halt(11);
if Max(t, sizeof(t))<>t then
halt(12);
if Max(i, t)<>t then
halt(13);
if Max(t, i)<>t then
halt(14);
if Max(sizeof(t),sizeof(t))<>sizeof(t) then
halt(15);
if Max(t,t)<>t then
halt(16);
if Max(i,i)<>i then
halt(17);
writeln('ok');
end.