mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 09:30:17 +02:00
* propertly check equality with the for-counter when propagating constants, resolves #39915
This commit is contained in:
parent
2bf377744a
commit
444fe092da
@ -142,7 +142,7 @@ unit optconstprop;
|
|||||||
begin
|
begin
|
||||||
CalcDefSum(tfornode(n).t2);
|
CalcDefSum(tfornode(n).t2);
|
||||||
{ the constant can propagete if is is not the counter variable ... }
|
{ the constant can propagete if is is not the counter variable ... }
|
||||||
if not(tassignmentnode(arg).left.isequal(tfornode(n).left)) and
|
if not(tassignmentnode(arg).left.isequal(actualtargetnode(@tfornode(n).left)^)) and
|
||||||
{ if it is a temprefn or its address is not taken in case of loadn }
|
{ if it is a temprefn or its address is not taken in case of loadn }
|
||||||
((tassignmentnode(arg).left.nodetype=temprefn) or not(tabstractvarsym(tloadnode(tassignmentnode(arg).left).symtableentry).addr_taken)) and
|
((tassignmentnode(arg).left.nodetype=temprefn) or not(tabstractvarsym(tloadnode(tassignmentnode(arg).left).symtableentry).addr_taken)) and
|
||||||
{ and no definition in the loop? }
|
{ and no definition in the loop? }
|
||||||
|
16
tests/webtbs/tw39915.pp
Normal file
16
tests/webtbs/tw39915.pp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ %OPT=-gt -O3 }
|
||||||
|
program project1;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
function CharPos(const S: AnsiString; const C: AnsiChar; const Index: SizeInt): SizeInt;
|
||||||
|
begin
|
||||||
|
for Result := Index to Length(S) do
|
||||||
|
if S[Result] = C then
|
||||||
|
Exit;
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Writeln(CharPos('Hello!', '!', 1));
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user