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

* fixed typed constants that use an integer number to initialise a procvar or
pointer on LLVM (fixes webtbs/tw21267)

git-svn-id: trunk@35059 -

Jonas Maebe пре 8 година
родитељ
комит
a0b537bc7b
1 измењених фајлова са 11 додато и 0 уклоњено
  1. 11 0
      compiler/llvm/nllvmtcon.pas

+ 11 - 0
compiler/llvm/nllvmtcon.pas

@@ -757,10 +757,21 @@ implementation
 
 
 
 
   procedure tllvmtai_typedconstbuilder.queue_emit_ordconst(value: int64; def: tdef);
   procedure tllvmtai_typedconstbuilder.queue_emit_ordconst(value: int64; def: tdef);
+    var
+      valuedef: tdef;
     begin
     begin
       { no offset into an ordinal constant }
       { no offset into an ordinal constant }
       if fqueue_offset<>0 then
       if fqueue_offset<>0 then
         internalerror(2015030702);
         internalerror(2015030702);
+      if not is_ordinal(def) then
+        begin
+          { insert an ordinal -> non-ordinal (e.g. pointer) conversion, as you
+            cannot have integer constants as pointer values in LLVM }
+          int_to_type(value,valuedef);
+          queue_typeconvn(valuedef,def);
+          { and now emit the constant as an ordinal }
+          def:=valuedef;
+        end;
       inherited;
       inherited;
     end;
     end;