mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-05 22:53:01 +01:00
* when range check error is found then fix the value to be within the
range
This commit is contained in:
parent
12ec9e475d
commit
901335c80d
@ -145,8 +145,9 @@ interface
|
|||||||
{ true if a function can be assigned to a procvar }
|
{ true if a function can be assigned to a procvar }
|
||||||
function proc_to_procvar_equal(def1,def2 : pabstractprocdef) : boolean;
|
function proc_to_procvar_equal(def1,def2 : pabstractprocdef) : boolean;
|
||||||
|
|
||||||
{ if l isn't in the range of def a range check error is generated }
|
{ if l isn't in the range of def a range check error is generated and
|
||||||
procedure testrange(def : pdef;l : longint);
|
the value is placed within the range }
|
||||||
|
procedure testrange(def : pdef;var l : longint);
|
||||||
|
|
||||||
{ returns the range of def }
|
{ returns the range of def }
|
||||||
procedure getrange(def : pdef;var l : longint;var h : longint);
|
procedure getrange(def : pdef;var l : longint;var h : longint);
|
||||||
@ -471,7 +472,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ test if l is in the range of def, outputs error if out of range }
|
{ test if l is in the range of def, outputs error if out of range }
|
||||||
procedure testrange(def : pdef;l : longint);
|
procedure testrange(def : pdef;var l : longint);
|
||||||
var
|
var
|
||||||
lv,hv: longint;
|
lv,hv: longint;
|
||||||
begin
|
begin
|
||||||
@ -506,10 +507,13 @@ implementation
|
|||||||
end
|
end
|
||||||
else if (l<lv) or (l>hv) then
|
else if (l<lv) or (l>hv) then
|
||||||
begin
|
begin
|
||||||
if (cs_check_range in aktlocalswitches) then
|
if (def^.deftype=enumdef) or
|
||||||
|
(cs_check_range in aktlocalswitches) then
|
||||||
Message(parser_e_range_check_error)
|
Message(parser_e_range_check_error)
|
||||||
else
|
else
|
||||||
Message(parser_w_range_check_error);
|
Message(parser_w_range_check_error);
|
||||||
|
{ Fix the value to be in range }
|
||||||
|
l:=lv+(l mod (hv-lv+1));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -872,7 +876,11 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.66 1999-05-28 11:00:51 peter
|
Revision 1.67 1999-05-31 22:54:19 peter
|
||||||
|
* when range check error is found then fix the value to be within the
|
||||||
|
range
|
||||||
|
|
||||||
|
Revision 1.66 1999/05/28 11:00:51 peter
|
||||||
* removed ungettempoftype
|
* removed ungettempoftype
|
||||||
|
|
||||||
Revision 1.65 1999/05/23 18:42:23 florian
|
Revision 1.65 1999/05/23 18:42:23 florian
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user