Parcourir la source

* nested open array constructors are not allowed, resolves #17213

git-svn-id: trunk@15876 -
florian il y a 15 ans
Parent
commit
700f687692
3 fichiers modifiés avec 22 ajouts et 0 suppressions
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/pexpr.pas
  3. 16 0
      tests/webtbs/tw17213.pp

+ 1 - 0
.gitattributes

@@ -10629,6 +10629,7 @@ tests/webtbs/tw17164.pp svneol=native#text/plain
 tests/webtbs/tw17180.pp svneol=native#text/plain
 tests/webtbs/tw17181.pp svneol=native#text/plain
 tests/webtbs/tw1720.pp svneol=native#text/plain
+tests/webtbs/tw17213.pp svneol=native#text/pascal
 tests/webtbs/tw1735.pp svneol=native#text/plain
 tests/webtbs/tw1737.pp svneol=native#text/plain
 tests/webtbs/tw1744.pp svneol=native#text/plain

+ 5 - 0
compiler/pexpr.pas

@@ -1712,6 +1712,7 @@ implementation
            p1,p2 : tnode;
            lastp,
            buildp : tarrayconstructornode;
+           old_allow_array_constructor : boolean;
          begin
            buildp:=nil;
          { be sure that a least one arrayconstructn is used, also for an
@@ -1720,6 +1721,9 @@ implementation
              buildp:=carrayconstructornode.create(nil,buildp)
            else
             repeat
+              { nested array constructors are not allowed, see also tests/webtbs/tw17213.pp }
+              old_allow_array_constructor:=allow_array_constructor;
+              allow_array_constructor:=false;
               p1:=comp_expr(true);
               if try_to_consume(_POINTPOINT) then
                 begin
@@ -1737,6 +1741,7 @@ implementation
                  lastp.right:=carrayconstructornode.create(p1,nil);
                  lastp:=tarrayconstructornode(lastp.right);
                end;
+             allow_array_constructor:=old_allow_array_constructor;
            { there could be more elements }
            until not try_to_consume(_COMMA);
            factor_read_set:=buildp;

+ 16 - 0
tests/webtbs/tw17213.pp

@@ -0,0 +1,16 @@
+program openarrayparam;
+{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
+{$ifdef mswindows}{$apptype console}{$endif}
+uses
+ sysutils;
+type
+ testflagty = (tf_1,tf2);
+ testflagsty = set of testflagty;
+
+procedure testproc(const testpar: array of testflagsty);
+begin
+end;
+
+begin
+ testproc([[],[],[]]);
+end.