فهرست منبع

* allow absolute on array of const parameters, resolves #41292

florian 1 ماه پیش
والد
کامیت
b6a686930a
2فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 2 1
      compiler/pdecvar.pas
  2. 13 0
      tests/webtbs/tw41292.pp

+ 2 - 1
compiler/pdecvar.pas

@@ -1329,8 +1329,9 @@ implementation
                   { the same size since it refers to the field and not to   }
                   { the same size since it refers to the field and not to   }
                   { the whole record -- which is why we use pt and not hp)  }
                   { the whole record -- which is why we use pt and not hp)  }
 
 
-                  { we can't take the size of an open array }
+                  { we can't take the size of an open array or an array of const }
                   if is_open_array(pt.resultdef) or
                   if is_open_array(pt.resultdef) or
+                     is_array_of_const(pt.resultdef) or
                      (vs.vardef.size <> pt.resultdef.size) then
                      (vs.vardef.size <> pt.resultdef.size) then
                     make_not_regable(pt,[ra_addr_regable]);
                     make_not_regable(pt,[ra_addr_regable]);
                 end
                 end

+ 13 - 0
tests/webtbs/tw41292.pp

@@ -0,0 +1,13 @@
+{$mode delphi}
+procedure proc(arg: array of const);
+var
+  p: array[0..999] of TVarRec absolute arg;
+begin
+  writeln(p[0].VInteger);
+  writeln(String(p[1].VPointer));
+  writeln(String(p[2].VPointer));
+end;
+
+begin
+  proc([100, 'foo', 'bar']);
+end.