mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 12:09:25 +02:00
* Fixed infinite loop when CONSTPROP is enabled
but USELOADMODIFYSTORE is not.
This commit is contained in:
parent
6ea4ddd3d5
commit
ef15d3d9ec
@ -224,13 +224,21 @@ unit optconstprop;
|
|||||||
if (tinlinenode(n).inlinenumber=in_dec_x) or (tinlinenode(n).inlinenumber=in_inc_x) then
|
if (tinlinenode(n).inlinenumber=in_dec_x) or (tinlinenode(n).inlinenumber=in_inc_x) then
|
||||||
begin
|
begin
|
||||||
if tnode(tassignmentnode(arg).left).isequal(tcallparanode(tinlinenode(n).left).left) and
|
if tnode(tassignmentnode(arg).left).isequal(tcallparanode(tinlinenode(n).left).left) and
|
||||||
(not(assigned(tcallparanode(tinlinenode(n).left).right)) or
|
{ Internal Inc/Dec flags are created through a tree transformation from
|
||||||
(tcallparanode(tcallparanode(tinlinenode(n).left).right).left.nodetype=ordconstn)) then
|
a previous ConstProp pass. Setting it prevents an infinite loop where
|
||||||
|
Inc/Dec nodes are converted into an Add/Sub tree, and then converted
|
||||||
|
back to Inc/Dec by the forced firstpass run }
|
||||||
|
not (nf_internal in n.flags) and
|
||||||
|
(
|
||||||
|
not(assigned(tcallparanode(tinlinenode(n).left).right)) or
|
||||||
|
(tcallparanode(tcallparanode(tinlinenode(n).left).right).left.nodetype=ordconstn)
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
{ if the node just being searched is inc'ed/dec'ed then replace the inc/dec
|
{ if the node just being searched is inc'ed/dec'ed then replace the inc/dec
|
||||||
by add/sub and force a second replacement pass }
|
by add/sub and force a second replacement pass }
|
||||||
oldnode:=n;
|
oldnode:=n;
|
||||||
n:=tinlinenode(n).getaddsub_for_incdec;
|
n:=tinlinenode(n).getaddsub_for_incdec;
|
||||||
|
Include(n.flags, nf_internal);
|
||||||
oldnode.free;
|
oldnode.free;
|
||||||
tree_modified:=true;
|
tree_modified:=true;
|
||||||
{ do not continue, value changed, if further const. propagations are possible, this is done
|
{ do not continue, value changed, if further const. propagations are possible, this is done
|
||||||
|
Loading…
Reference in New Issue
Block a user