mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 05:29:18 +02:00
* set varstate before parsing the instruction block in for statements
This commit is contained in:
parent
523f429d7a
commit
e24eb1f631
@ -679,6 +679,11 @@ implementation
|
||||
result:=nil;
|
||||
resulttype:=voidtype;
|
||||
|
||||
{ process the loopvar, from and to, varstates are already set }
|
||||
resulttypepass(left);
|
||||
resulttypepass(right);
|
||||
resulttypepass(t1);
|
||||
|
||||
{Can we spare the first comparision?}
|
||||
if (t1.nodetype=ordconstn) and
|
||||
(right.nodetype=ordconstn) and
|
||||
@ -694,18 +699,6 @@ implementation
|
||||
) then
|
||||
exclude(loopflags,lnf_testatbegin);
|
||||
|
||||
{ process the loopvar, from and to }
|
||||
resulttypepass(left);
|
||||
resulttypepass(right);
|
||||
resulttypepass(t1);
|
||||
|
||||
{ first set the varstate for from and to, so
|
||||
uses of loopvar in those expressions will also
|
||||
trigger a warning when it is not used yet }
|
||||
set_varstate(right,vs_used,true);
|
||||
set_varstate(t1,vs_used,true);
|
||||
set_varstate(left,vs_used,false);
|
||||
|
||||
{ Make sure that the loop var and the
|
||||
from and to values are compatible types }
|
||||
inserttypeconv(right,left.resulttype);
|
||||
@ -1401,7 +1394,10 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.107 2005-01-31 16:16:21 peter
|
||||
Revision 1.108 2005-01-31 20:23:53 peter
|
||||
* set varstate before parsing the instruction block in for statements
|
||||
|
||||
Revision 1.107 2005/01/31 16:16:21 peter
|
||||
* for-node cleanup, checking for uninitialzed from and to values
|
||||
is now supported
|
||||
|
||||
|
@ -387,10 +387,22 @@ implementation
|
||||
hto:=comp_expr(true);
|
||||
consume(_DO);
|
||||
|
||||
{ first set the varstate for from and to, so
|
||||
uses of loopvar in those expressions will also
|
||||
trigger a warning when it is not used yet. This
|
||||
needs to be done before the instruction block is
|
||||
parsed to have a valid hloopvar }
|
||||
resulttypepass(hfrom);
|
||||
set_varstate(hfrom,vs_used,true);
|
||||
resulttypepass(hto);
|
||||
set_varstate(hto,vs_used,true);
|
||||
resulttypepass(hloopvar);
|
||||
set_varstate(hloopvar,vs_used,false);
|
||||
|
||||
{ ... now the instruction block }
|
||||
hblock:=statement;
|
||||
|
||||
{ variable is not used a loop counter anymore }
|
||||
{ variable is not used for loop counter anymore }
|
||||
if assigned(loopvarsym) then
|
||||
exclude(loopvarsym.varoptions,vo_is_loop_counter);
|
||||
|
||||
@ -1145,7 +1157,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.150 2005-01-31 16:16:21 peter
|
||||
Revision 1.151 2005-01-31 20:23:53 peter
|
||||
* set varstate before parsing the instruction block in for statements
|
||||
|
||||
Revision 1.150 2005/01/31 16:16:21 peter
|
||||
* for-node cleanup, checking for uninitialzed from and to values
|
||||
is now supported
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user