* only allow using array elements as for-loop counter variables

in TP mode

git-svn-id: trunk@8907 -
This commit is contained in:
Jonas Maebe 2007-10-21 22:39:49 +00:00
parent e64b973cf9
commit 12b4f034ea
5 changed files with 40 additions and 9 deletions

2
.gitattributes vendored
View File

@ -7487,6 +7487,8 @@ tests/webtbf/tw9039b.pp svneol=native#text/plain
tests/webtbf/tw9039c.pp svneol=native#text/plain
tests/webtbf/tw9039d.pp svneol=native#text/plain
tests/webtbf/tw9053.pp svneol=native#text/plain
tests/webtbf/tw9072a.pp svneol=native#text/plain
tests/webtbf/tw9072b.pp svneol=native#text/plain
tests/webtbf/tw9225.pp svneol=native#text/plain
tests/webtbf/tw9306c.pp svneol=native#text/plain
tests/webtbf/tw9499.pp svneol=native#text/plain

View File

@ -325,17 +325,21 @@ implementation
hp:=hloopvar;
while assigned(hp) and
(
{ record/object fields are allowed in tp7 mode only }
{ record/object fields and array elements are allowed }
{ in tp7 mode only }
(
(m_tp7 in current_settings.modeswitches) and
(hp.nodetype=subscriptn) and
((tsubscriptnode(hp).left.resultdef.typ=recorddef) or
is_object(tsubscriptnode(hp).left.resultdef))
) or
{ constant array index }
(
(hp.nodetype=vecn) and
is_constintnode(tvecnode(hp).right)
(
((hp.nodetype=subscriptn) and
((tsubscriptnode(hp).left.resultdef.typ=recorddef) or
is_object(tsubscriptnode(hp).left.resultdef))
) or
{ constant array index }
(
(hp.nodetype=vecn) and
is_constintnode(tvecnode(hp).right)
)
)
) or
{ equal typeconversions }
(

11
tests/webtbf/tw9072a.pp Normal file
View File

@ -0,0 +1,11 @@
{ %fail }
{$mode tp}
var
a: array[1..10] of byte;
b: byte;
begin
b:=1;
for a[b] := 1 to 10 do ;
end.

12
tests/webtbf/tw9072b.pp Normal file
View File

@ -0,0 +1,12 @@
{ %fail }
var
a: array[1..2] of longint;
l: longint;
begin
l:=0;
for a[1]:=1 to 10 do
inc(l);
if (l<>10) then
halt(1);
end.

View File

@ -3,6 +3,8 @@
{ e-mail: wingo@fh-konstanz.de }
{ compiled with 1.04 on win32 }
{ options : -B -CX -XXs -OG2p3 -So }
{$mode tp}
var
a : array[1..10] of integer;
i : byte;