ソースを参照

* set the rangedef of open arrays to ptrsinttype (instead of s32inttype),
so that it's the same as the def returned by the low/high nodes
(mantis #25703)

git-svn-id: trunk@27970 -

Jonas Maebe 11 年 前
コミット
24f4adf657
4 ファイル変更22 行追加3 行削除
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/defutil.pas
  3. 1 1
      compiler/pdecsub.pas
  4. 18 0
      tests/webtbs/tw25703.pp

+ 1 - 0
.gitattributes

@@ -13940,6 +13940,7 @@ tests/webtbs/tw25605.pp svneol=native#text/pascal
 tests/webtbs/tw2561.pp svneol=native#text/plain
 tests/webtbs/tw25610.pp -text svneol=native#text/plain
 tests/webtbs/tw25685.pp svneol=native#text/pascal
+tests/webtbs/tw25703.pp svneol=native#text/plain
 tests/webtbs/tw25781.pp svneol=native#text/plain
 tests/webtbs/tw25814.pp svneol=native#text/plain
 tests/webtbs/tw25869.pp svneol=native#text/plain

+ 2 - 2
compiler/defutil.pas

@@ -685,10 +685,10 @@ implementation
     { true, if p points to an open array def }
     function is_open_array(p : tdef) : boolean;
       begin
-         { check for s32inttype is needed, because for u32bit the high
+         { check for ptrsinttype is needed, because for unsigned the high
            range is also -1 ! (PFV) }
          result:=(p.typ=arraydef) and
-                 (tarraydef(p).rangedef=s32inttype) and
+                 (tarraydef(p).rangedef=ptrsinttype) and
                  (tarraydef(p).lowrange=0) and
                  (tarraydef(p).highrange=-1) and
                  ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])=[]);

+ 1 - 1
compiler/pdecsub.pas

@@ -399,7 +399,7 @@ implementation
                 consume(_ARRAY);
                 consume(_OF);
                 { define range and type of range }
-                hdef:=carraydef.create(0,-1,s32inttype);
+                hdef:=carraydef.create(0,-1,ptrsinttype);
                 { array of const ? }
                 if (token=_CONST) and (m_objpas in current_settings.modeswitches) then
                  begin

+ 18 - 0
tests/webtbs/tw25703.pp

@@ -0,0 +1,18 @@
+{ %norun }
+{ %opt=-CO -Seh }
+
+{$MODE OBJFPC}
+type
+   TNode = class end;
+
+procedure Test(const Arg: array of TNode);
+var
+   Item: TNode;
+begin
+   for Item in Arg do ; // Warning here
+end;
+
+begin
+  test([]);
+end.
+