fcl-passrc: resolver: fixed high(intvar)

git-svn-id: trunk@39906 -
This commit is contained in:
Mattias Gaertner 2018-10-09 11:17:00 +00:00
parent 9d7308df42
commit 27a9d53dd2
3 changed files with 17 additions and 6 deletions

View File

@ -12577,9 +12577,8 @@ begin
Param:=Params.Params[0];
ComputeElement(Param,ParamResolved,[]);
Result:=cIncompatible;
if not (rrfReadable in ParamResolved.Flags)
and (ParamResolved.BaseType in btAllRanges) then
// built-in range e.g. high(char)
if ParamResolved.BaseType in btAllRanges then
// e.g. high(char)
Result:=cExact
else if ParamResolved.BaseType=btSet then
Result:=cExact
@ -12592,7 +12591,12 @@ begin
Result:=cExact;
end;
if Result=cIncompatible then
begin
{$IFDEF VerbosePasResolver}
writeln('TPasResolver.BI_LowHigh_OnGetCallCompatibility ParamResolved=',GetResolverResultDbg(ParamResolved));
{$ENDIF}
exit(CheckRaiseTypeArgNo(20170216152338,1,Param,ParamResolved,'ordinal type, array or set',RaiseOnError));
end;
Result:=CheckBuiltInMaxParamCount(Proc,Params,1,RaiseOnError);
end;

View File

@ -3016,8 +3016,12 @@ begin
' MaxInt = +10;',
'type',
' {#TMyInt}TMyInt = MinInt..MaxInt;',
'const a = low(TMyInt)+High(TMyInt);',
'begin']);
'const',
' a = low(TMyInt)+High(TMyInt);',
'var',
' i: TMyInt;',
'begin',
' i:=low(i)+high(i);']);
ParseProgram;
CheckResolverUnexpectedHints;
end;

View File

@ -5316,7 +5316,9 @@ begin
' i: TMyInt;',
'begin',
' i:=-MinInt;',
' i:=default(TMyInt);']);
' i:=default(TMyInt);',
' i:=low(i)+high(i);',
'']);
ConvertProgram;
CheckSource('TestIntegerRange',
LinesToStr([
@ -5328,6 +5330,7 @@ begin
LinesToStr([
'$mod.i = - -4503599627370496;',
'$mod.i = -4503599627370496;',
'$mod.i = -4503599627370496 + 4503599627370495;',
'']));
end;