Browse Source

* when converting a pointer-sized entity to a complex procvar in a typed
const builder, it can only initialise the function pointer part of the
complex procvar -> convert the to-size to an address-only version of
the complex procvar to avoid us trying to bitcast an address into a
record containing both the function and self/nestedfp pointer
(fixes test/tmaclocalprocparam4e for llvm)

git-svn-id: trunk@34118 -

Jonas Maebe 9 years ago
parent
commit
5541fb3f6d
1 changed files with 8 additions and 0 deletions
  1. 8 0
      compiler/llvm/nllvmtcon.pas

+ 8 - 0
compiler/llvm/nllvmtcon.pas

@@ -675,6 +675,14 @@ implementation
       if (fromdef.typ=procdef) and
          (todef.typ<>procdef) then
         fromdef:=cprocvardef.getreusableprocaddr(tprocdef(fromdef));
+      { typecasting a pointer-sized entity to a complex procvardef -> convert
+        to the pointer-component of the complex procvardef (not always, because
+        e.g. a tmethod to complex procvar initialises the entire complex
+        procvar) }
+      if (todef.typ=procvardef) and
+         not tprocvardef(todef).is_addressonly and
+         (fromdef.size<todef.size) then
+        todef:=cprocvardef.getreusableprocaddr(tprocvardef(todef));
       op:=llvmconvop(fromdef,todef,false);
       case op of
         la_ptrtoint_to_x,