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
This commit is contained in:
Jonas Maebe 2023-01-03 21:17:58 +01:00
parent 84ea64e59c
commit a641860fa8

View File

@ -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;