mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 14:08:09 +02:00
* only allow using array elements as for-loop counter variables
in TP mode git-svn-id: trunk@8907 -
This commit is contained in:
parent
e64b973cf9
commit
12b4f034ea
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -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
|
||||
|
@ -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
11
tests/webtbf/tw9072a.pp
Normal 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
12
tests/webtbf/tw9072b.pp
Normal 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.
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user