浏览代码

* take into account the fact that bitpacked ordinal fields are all encoded
as bytes in the LLVM type, so typecast them to the correct type (which is
the size that will be used by hlcg.a_load*subsetref*)

git-svn-id: trunk@32565 -

Jonas Maebe 9 年之前
父节点
当前提交
8df979e5e8
共有 1 个文件被更改,包括 15 次插入1 次删除
  1. 15 1
      compiler/llvm/nllvmmem.pas

+ 15 - 1
compiler/llvm/nllvmmem.pas

@@ -66,6 +66,7 @@ implementation
     function tllvmsubscriptnode.handle_platform_subscript: boolean;
       var
         newbase: tregister;
+        fielddef: tdef;
       begin
         if not(location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
           internalerror(2014011905);
@@ -74,7 +75,20 @@ implementation
             { typecast the result to the expected type, but don't actually index
               (that still has to be done by the generic code, so return false) }
             newbase:=hlcg.getaddressregister(current_asmdata.CurrAsmList,cpointerdef.getreusable(resultdef));
-            hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.resultdef,cpointerdef.getreusable(resultdef),location.reference,newbase);
+            if is_ordinal(resultdef) and
+               (resultdef.packedbitsize mod 8<>0) then
+              fielddef:=
+                cgsize_orddef(
+                  int_cgsize(
+                    packedbitsloadsize(resultdef.packedbitsize)
+                  )
+                )
+            else
+              fielddef:=resultdef;
+            hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,
+              left.resultdef,
+              cpointerdef.getreusable(fielddef),
+              location.reference,newbase);
             reference_reset_base(location.reference,newbase,0,location.reference.alignment);
             result:=false;
           end