Kaynağa Gözat

Implicit specialisation: use regular array parameters for array constructors

Fixes compilation of test/timpfuncspez5 with LLVM and debug info, as the LLVM
debug info writer internalerror's when you try to generate debug info for
an array constructor (since those types should never appear as parameter/
variable types).

Replace them with reusable regular array types, so that multiple invocations
of the same generic function with array constructors of the same type and
number of elements are collapsed into the same specialisation
Jonas Maebe 2 yıl önce
ebeveyn
işleme
a641860fa8
1 değiştirilmiş dosya ile 7 ekleme ve 0 silme
  1. 7 0
      compiler/pgenutil.pas

+ 7 - 0
compiler/pgenutil.pas

@@ -763,6 +763,13 @@ uses
             newtype:=tstringdef(def).get_default_string_type.typesym
           else
             begin
+              if is_array_constructor(def) then
+                begin
+                  { array constructor is not a valid parameter type; getreusable
+                    avoids creating multiple implementations for calls with the
+                    same number of array elements of a particular type }
+                  def:=carraydef.getreusable(tarraydef(def).elementdef,tarraydef(def).highrange-tarraydef(def).lowrange+1);
+                end;
               newtype:=ctypesym.create(def.fullownerhierarchyname(false)+typName[def.typ]+'$'+def.unique_id_str,def);
               include(newtype.symoptions,sp_generic_unnamed_type);
               newtype.owner:=def.owner;