mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 06:29:32 +02:00
compiler:
- fix for-in loop for empty sets - add some test from Alexander S. Klenin (issue #0014990) git-svn-id: trunk@14042 -
This commit is contained in:
parent
5752be310d
commit
61ec5e1417
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -8235,6 +8235,8 @@ tests/test/tforin14.pp svneol=native#text/pascal
|
||||
tests/test/tforin15.pp svneol=native#text/pascal
|
||||
tests/test/tforin16.pp svneol=native#text/pascal
|
||||
tests/test/tforin17.pp svneol=native#text/pascal
|
||||
tests/test/tforin18.pp svneol=native#text/pascal
|
||||
tests/test/tforin19.pp svneol=native#text/pascal
|
||||
tests/test/tforin2.pp svneol=native#text/pascal
|
||||
tests/test/tforin3.pp svneol=native#text/pascal
|
||||
tests/test/tforin4.pp svneol=native#text/pascal
|
||||
|
@ -390,6 +390,15 @@ var
|
||||
loopvar, setvar: ttempcreatenode;
|
||||
loopbody, forloopnode: tnode;
|
||||
begin
|
||||
// first check is set is empty and if it so then skip other processing
|
||||
if not Assigned(tsetdef(expr.resultdef).elementdef) then
|
||||
begin
|
||||
result:=cnothingnode.create;
|
||||
// free unused nodes
|
||||
hloopvar.free;
|
||||
hloopbody.free;
|
||||
exit;
|
||||
end;
|
||||
{ result is a block of statements }
|
||||
result:=internalstatements(loopstatement);
|
||||
|
||||
|
6
tests/test/tforin18.pp
Normal file
6
tests/test/tforin18.pp
Normal file
@ -0,0 +1,6 @@
|
||||
{ %FAIL}
|
||||
{$mode objfpc}
|
||||
{$apptype console}
|
||||
begin
|
||||
for ch in S do Writeln(ch);
|
||||
end.
|
7
tests/test/tforin19.pp
Normal file
7
tests/test/tforin19.pp
Normal file
@ -0,0 +1,7 @@
|
||||
{$mode objfpc}
|
||||
{$apptype console}
|
||||
var
|
||||
ch: Char;
|
||||
begin
|
||||
for ch in [] do Writeln(ch);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user