Преглед изворни кода

* pass "const" arrays always by reference, because there is a lot of hacky
code out there that relies on this, even though it's not supposed to be
guaranteed in any way :(

git-svn-id: trunk@29874 -

Jonas Maebe пре 10 година
родитељ
комит
820de6a17b
1 измењених фајлова са 8 додато и 3 уклоњено
  1. 8 3
      compiler/aarch64/cpupara.pas

+ 8 - 3
compiler/aarch64/cpupara.pas

@@ -259,7 +259,11 @@ unit cpupara;
           formaldef:
             result:=true;
           { arrays are composites and hence treated the same as records by the
-            ABI (watch out for C, where an array is a pointer) }
+            ABI (watch out for C, where an array is a pointer)
+            Also: all other platforms pass const arrays by reference. Do the
+              same here, because there is too much hacky code out there that
+              relies on this ("array[0..0] of x" passed as const parameter and
+              then indexed beyond its bounds) }
           arraydef:
             result:=
               (calloption in cdecl_pocalls) or
@@ -267,8 +271,9 @@ unit cpupara;
               is_array_of_const(def) or
               is_array_constructor(def) or
               ((tarraydef(def).highrange>=tarraydef(def).lowrange) and
-               not is_hfa(def,hfabasedef) and
-               (def.size>16));
+               ((varspez=vs_const) or
+                (not is_hfa(def,hfabasedef) and
+                 (def.size>16))));
           setdef :
             result:=def.size>16;
           stringdef :