Browse Source

* reuse a reference when resizing ordinal values to smaller sizes,
this is required for constructions like byte(w):=1 that are
allowed in tp mode only

peter 23 years ago
parent
commit
88dce133e4
1 changed files with 13 additions and 3 deletions
  1. 13 3
      compiler/ncgcnv.pas

+ 13 - 3
compiler/ncgcnv.pas

@@ -86,9 +86,14 @@ interface
         { is the result size smaller ? }
         if resulttype.def.size<>left.resulttype.def.size then
           begin
-            { reuse the left location by default }
             location_copy(location,left.location);
-            location_force_reg(exprasmlist,location,newsize,false);
+            { reuse a loc_reference when the newsize is smaller than
+              than the original, else load it to a register }
+            if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
+               (resulttype.def.size<left.resulttype.def.size) then
+             location.size:=newsize
+            else
+             location_force_reg(exprasmlist,location,newsize,false);
           end
         else
           begin
@@ -491,7 +496,12 @@ end.
 
 {
   $Log$
-  Revision 1.28  2002-08-25 09:06:58  peter
+  Revision 1.29  2002-09-02 18:46:00  peter
+    * reuse a reference when resizing ordinal values to smaller sizes,
+      this is required for constructions like byte(w):=1 that are
+      allowed in tp mode only
+
+  Revision 1.28  2002/08/25 09:06:58  peter
     * add calls to release temps
 
   Revision 1.27  2002/08/23 16:14:48  peter