mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 14:50:32 +02:00
compiler: change candidates search preference for variant arguments based on testing delphi XE + fixing tests
before the change order was (from better to worse): shortstring, ansistring, widestring, unicodestring now the order is (from better to worse): widestring, unicodestring, ansistring, shortstring git-svn-id: trunk@20907 -
This commit is contained in:
parent
6244671000
commit
b80e7c8fba
@ -2655,18 +2655,19 @@ implementation
|
|||||||
{ Delphi precedence rules extracted from test programs. Only valid if passing
|
{ Delphi precedence rules extracted from test programs. Only valid if passing
|
||||||
a variant parameter to overloaded procedures expecting exactly one parameter.
|
a variant parameter to overloaded procedures expecting exactly one parameter.
|
||||||
|
|
||||||
single > (char, currency, int64, shortstring, ansistring, widestring, extended, double)
|
single > (char, currency, int64, shortstring, ansistring, widestring, unicodestring, extended, double)
|
||||||
double/currency > (char, int64, shortstring, ansistring, widestring, extended)
|
double/currency > (char, int64, shortstring, ansistring, widestring, unicodestring, extended)
|
||||||
extended > (char, int64, shortstring, ansistring, widestring)
|
extended > (char, int64, shortstring, ansistring, widestring, unicodestring)
|
||||||
longint/cardinal > (int64, shortstring, ansistring, widestring, extended, double, single, char, currency)
|
longint/cardinal > (int64, shortstring, ansistring, widestring, unicodestring, extended, double, single, char, currency)
|
||||||
smallint > (longint, int64, shortstring, ansistring, widestring, extended, double single, char, currency);
|
smallint > (longint, int64, shortstring, ansistring, widestring, unicodestring, extended, double single, char, currency);
|
||||||
word > (longint, cardinal, int64, shortstring, ansistring, widestring, extended, double single, char, currency);
|
word > (longint, cardinal, int64, shortstring, ansistring, widestring, unicodestring, extended, double single, char, currency);
|
||||||
shortint > (longint, smallint, int64, shortstring, ansistring, widestring, extended, double, single, char, currency)
|
shortint > (longint, smallint, int64, shortstring, ansistring, widestring, unicodestring, extended, double, single, char, currency)
|
||||||
byte > (longint, cardinal, word, smallint, int64, shortstring, ansistring, widestring, extended, double, single, char, currency);
|
byte > (longint, cardinal, word, smallint, int64, shortstring, ansistring, widestring, unicodestring, extended, double, single, char, currency);
|
||||||
boolean/formal > (char, int64, shortstring, ansistring, widestring)
|
boolean/formal > (char, int64, shortstring, ansistring, widestring, unicodestring)
|
||||||
shortstring > (char, int64, ansistring, widestring)
|
widestring > (char, int64, shortstring, ansistring, unicodestring)
|
||||||
ansistring > (char, int64, widestring)
|
unicodestring > (char, int64, shortstring, ansistring)
|
||||||
widestring > (char, int64)
|
ansistring > (char, int64, shortstring)
|
||||||
|
shortstring > (char, int64)
|
||||||
|
|
||||||
Relations not mentioned mean that they conflict: no decision possible }
|
Relations not mentioned mean that they conflict: no decision possible }
|
||||||
|
|
||||||
@ -2788,14 +2789,6 @@ implementation
|
|||||||
else if (currvcl=tve_extended) or
|
else if (currvcl=tve_extended) or
|
||||||
(bestvcl=tve_extended) then
|
(bestvcl=tve_extended) then
|
||||||
result:=1-2*ord(bestvcl=tve_extended)
|
result:=1-2*ord(bestvcl=tve_extended)
|
||||||
{ shortstring is better than everything left }
|
|
||||||
else if (currvcl=tve_sstring) or
|
|
||||||
(bestvcl=tve_sstring) then
|
|
||||||
result:=1-2*ord(bestvcl=tve_sstring)
|
|
||||||
{ ansistring is better than everything left }
|
|
||||||
else if (currvcl=tve_astring) or
|
|
||||||
(bestvcl=tve_astring) then
|
|
||||||
result:=1-2*ord(bestvcl=tve_astring)
|
|
||||||
{ widestring is better than everything left }
|
{ widestring is better than everything left }
|
||||||
else if (currvcl=tve_wstring) or
|
else if (currvcl=tve_wstring) or
|
||||||
(bestvcl=tve_wstring) then
|
(bestvcl=tve_wstring) then
|
||||||
@ -2803,7 +2796,15 @@ implementation
|
|||||||
{ unicodestring is better than everything left }
|
{ unicodestring is better than everything left }
|
||||||
else if (currvcl=tve_ustring) or
|
else if (currvcl=tve_ustring) or
|
||||||
(bestvcl=tve_ustring) then
|
(bestvcl=tve_ustring) then
|
||||||
result:=1-2*ord(bestvcl=tve_ustring);
|
result:=1-2*ord(bestvcl=tve_ustring)
|
||||||
|
{ ansistring is better than everything left }
|
||||||
|
else if (currvcl=tve_astring) or
|
||||||
|
(bestvcl=tve_astring) then
|
||||||
|
result:=1-2*ord(bestvcl=tve_astring)
|
||||||
|
{ shortstring is better than everything left }
|
||||||
|
else if (currvcl=tve_sstring) or
|
||||||
|
(bestvcl=tve_sstring) then
|
||||||
|
result:=1-2*ord(bestvcl=tve_sstring);
|
||||||
|
|
||||||
{ all possibilities should have been checked now }
|
{ all possibilities should have been checked now }
|
||||||
if (result=-5) then
|
if (result=-5) then
|
||||||
|
@ -559,10 +559,10 @@ type
|
|||||||
tvariantequaltype = (
|
tvariantequaltype = (
|
||||||
tve_incompatible,
|
tve_incompatible,
|
||||||
tve_chari64,
|
tve_chari64,
|
||||||
tve_ustring,
|
|
||||||
tve_wstring,
|
|
||||||
tve_astring,
|
|
||||||
tve_sstring,
|
tve_sstring,
|
||||||
|
tve_astring,
|
||||||
|
tve_wstring,
|
||||||
|
tve_ustring,
|
||||||
tve_boolformal,
|
tve_boolformal,
|
||||||
tve_extended,
|
tve_extended,
|
||||||
tve_dblcurrency,
|
tve_dblcurrency,
|
||||||
|
@ -15,12 +15,12 @@ type
|
|||||||
procedure test136(a: shortstring); overload;
|
procedure test136(a: shortstring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('shortstring called instead of ansistring');
|
writeln('shortstring called instead of ansistring');
|
||||||
|
halt(1)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure test136(a: ansistring); overload;
|
procedure test136(a: ansistring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('ansistring called instead of shortstring');
|
writeln('ansistring called instead of shortstring');
|
||||||
halt(1)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -15,12 +15,12 @@ type
|
|||||||
procedure test142(a: shortstring); overload;
|
procedure test142(a: shortstring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('shortstring called instead of widestring');
|
writeln('shortstring called instead of widestring');
|
||||||
|
halt(1)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure test142(a: widestring); overload;
|
procedure test142(a: widestring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('widestring called instead of shortstring');
|
writeln('widestring called instead of shortstring');
|
||||||
halt(1)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -15,12 +15,12 @@ type
|
|||||||
procedure test149(a: ansistring); overload;
|
procedure test149(a: ansistring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('ansistring called instead of widestring');
|
writeln('ansistring called instead of widestring');
|
||||||
|
halt(1)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure test149(a: widestring); overload;
|
procedure test149(a: widestring); overload;
|
||||||
begin
|
begin
|
||||||
writeln('widestring called instead of ansistring');
|
writeln('widestring called instead of ansistring');
|
||||||
halt(1)
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user