Browse Source

* fixed types for shortstring handling in tcgassignmentnode.pass_generate_code

git-svn-id: trunk@30716 -
Jonas Maebe 10 years ago
parent
commit
388cef8a34
1 changed files with 10 additions and 5 deletions
  1. 10 5
      compiler/ncgld.pas

+ 10 - 5
compiler/ncgld.pas

@@ -667,19 +667,23 @@ implementation
             if is_shortstring(right.resultdef) and
             if is_shortstring(right.resultdef) and
                (right.nodetype in [blockn,calln]) then
                (right.nodetype in [blockn,calln]) then
               begin
               begin
-                { nothing to do }
+                { verify that we indeed have nothing to do }
+                if not(nf_assign_done_in_right in flags) then
+                  internalerror(2015042201);
               end
               end
             { empty constant string }
             { empty constant string }
             else if (right.nodetype=stringconstn) and
             else if (right.nodetype=stringconstn) and
                (tstringconstnode(right).len=0) then
                (tstringconstnode(right).len=0) then
               begin
               begin
-                hlcg.a_load_const_ref(current_asmdata.CurrAsmList,u8inttype,0,left.location.reference);
+                hlcg.g_ptrtypecast_ref(current_asmdata.CurrAsmList,getpointerdef(left.resultdef),tpointerdef(charpointertype),left.location.reference);
+                hlcg.a_load_const_ref(current_asmdata.CurrAsmList,cansichartype,0,left.location.reference);
               end
               end
             { char loading }
             { char loading }
             else if is_char(right.resultdef) then
             else if is_char(right.resultdef) then
               begin
               begin
                 if right.nodetype=ordconstn then
                 if right.nodetype=ordconstn then
                   begin
                   begin
+                    hlcg.g_ptrtypecast_ref(current_asmdata.CurrAsmList,getpointerdef(left.resultdef),getpointerdef(u16inttype),left.location.reference);
                     if (target_info.endian = endian_little) then
                     if (target_info.endian = endian_little) then
                       hlcg.a_load_const_ref(current_asmdata.CurrAsmList,u16inttype,(tordconstnode(right).value.svalue shl 8) or 1,
                       hlcg.a_load_const_ref(current_asmdata.CurrAsmList,u16inttype,(tordconstnode(right).value.svalue shl 8) or 1,
                           setalignment(left.location.reference,1))
                           setalignment(left.location.reference,1))
@@ -690,7 +694,8 @@ implementation
                 else
                 else
                   begin
                   begin
                     href:=left.location.reference;
                     href:=left.location.reference;
-                    hlcg.a_load_const_ref(current_asmdata.CurrAsmList,u8inttype,1,href);
+                    hlcg.g_ptrtypecast_ref(current_asmdata.CurrAsmList,getpointerdef(left.resultdef),tpointerdef(charpointertype),href);
+                    hlcg.a_load_const_ref(current_asmdata.CurrAsmList,cansichartype,1,href);
                     inc(href.offset,1);
                     inc(href.offset,1);
                     case right.location.loc of
                     case right.location.loc of
                       LOC_REGISTER,
                       LOC_REGISTER,
@@ -700,13 +705,13 @@ implementation
                           r:=cg.makeregsize(current_asmdata.CurrAsmList,right.location.register,OS_8);
                           r:=cg.makeregsize(current_asmdata.CurrAsmList,right.location.register,OS_8);
 {$else not cpuhighleveltarget}
 {$else not cpuhighleveltarget}
                           r:=hlcg.getintregister(current_asmdata.CurrAsmList,u8inttype);
                           r:=hlcg.getintregister(current_asmdata.CurrAsmList,u8inttype);
-                          hlcg.a_load_reg_reg(current_asmdata.CurrAsmList,u8inttype,u8inttype,right.location.register,r);
+                          hlcg.a_load_reg_reg(current_asmdata.CurrAsmList,cansichartype,u8inttype,right.location.register,r);
 {$endif cpuhighleveltarget}
 {$endif cpuhighleveltarget}
                           hlcg.a_load_reg_ref(current_asmdata.CurrAsmList,u8inttype,u8inttype,r,href);
                           hlcg.a_load_reg_ref(current_asmdata.CurrAsmList,u8inttype,u8inttype,r,href);
                         end;
                         end;
                       LOC_REFERENCE,
                       LOC_REFERENCE,
                       LOC_CREFERENCE :
                       LOC_CREFERENCE :
-                        hlcg.a_load_ref_ref(current_asmdata.CurrAsmList,u8inttype,u8inttype,right.location.reference,href);
+                        hlcg.a_load_ref_ref(current_asmdata.CurrAsmList,cansichartype,cansichartype,right.location.reference,href);
                       else
                       else
                         internalerror(200205111);
                         internalerror(200205111);
                     end;
                     end;