* prohibit static array constants inside dynamic array constants for Delphi modes

+ added test

git-svn-id: trunk@39045 -
This commit is contained in:
svenbarth 2018-05-20 11:50:27 +00:00
parent 31a9ed573c
commit dcdb151add
3 changed files with 23 additions and 0 deletions

1
.gitattributes vendored
View File

@ -12504,6 +12504,7 @@ tests/test/tarray13.pp svneol=native#text/pascal
tests/test/tarray14.pp svneol=native#text/pascal
tests/test/tarray15.pp svneol=native#text/pascal
tests/test/tarray16.pp svneol=native#text/pascal
tests/test/tarray17.pp svneol=native#text/pascal
tests/test/tarray2.pp svneol=native#text/plain
tests/test/tarray3.pp svneol=native#text/plain
tests/test/tarray4.pp svneol=native#text/plain

View File

@ -1197,6 +1197,16 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
end
else
begin
{ Delphi does not correctly parse static array constants
inside dynamic array constants. Additionally static and
dynamic array constants use different syntaxes ("(...)"
vs. "[...]"), so it's safer we simply disallow it until
the Delphi developers clears up this mess if ever }
if (m_delphi in current_settings.modeswitches) and
(def.elementdef.typ=arraydef) and
not is_dynamic_array(def.elementdef) then
Message(parser_e_no_static_array_const_in_dynarray_const);
if fsym.varspez=vs_const then
sectype:=sec_rodata
else

12
tests/test/tarray17.pp Normal file
View File

@ -0,0 +1,12 @@
{ %FAIL }
program tarray17;
{$mode delphi}
var
v1: array of array[0..2] of LongInt = [(1, 2, 3), (4, 5, 6)];
begin
end.