diff --git a/.gitattributes b/.gitattributes index 576b60217c..a2bb4a8c5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas index 6af71567c9..e12ccc2cd8 100644 --- a/compiler/pstatmnt.pas +++ b/compiler/pstatmnt.pas @@ -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 } ( diff --git a/tests/webtbf/tw9072a.pp b/tests/webtbf/tw9072a.pp new file mode 100644 index 0000000000..18aaf65163 --- /dev/null +++ b/tests/webtbf/tw9072a.pp @@ -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. diff --git a/tests/webtbf/tw9072b.pp b/tests/webtbf/tw9072b.pp new file mode 100644 index 0000000000..3238c1b013 --- /dev/null +++ b/tests/webtbf/tw9072b.pp @@ -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. diff --git a/tests/webtbs/tw1407.pp b/tests/webtbs/tw1407.pp index cb30bda9e6..5fe12e06ef 100644 --- a/tests/webtbs/tw1407.pp +++ b/tests/webtbs/tw1407.pp @@ -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;