فهرست منبع

+ avr: overflow checking for abs, together with the other recent abs-related commits, resolves #40694

florian 1 سال پیش
والد
کامیت
e7716dc05f
1فایلهای تغییر یافته به همراه7 افزوده شده و 3 حذف شده
  1. 7 3
      compiler/avr/navrinl.pas

+ 7 - 3
compiler/avr/navrinl.pas

@@ -40,7 +40,7 @@ unit navrinl;
   implementation
   implementation
 
 
     uses
     uses
-      verbose,
+      verbose,globtype,globals,
       constexp,
       constexp,
       compinnr,
       compinnr,
       aasmdata,
       aasmdata,
@@ -57,19 +57,23 @@ unit navrinl;
       var
       var
         hl: TAsmLabel;
         hl: TAsmLabel;
         size: TCgSize;
         size: TCgSize;
+        dummyloc: tlocation;
       begin
       begin
         secondpass(left);
         secondpass(left);
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
 
 
         location:=left.location;
         location:=left.location;
-        location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,left.resultdef);
+        location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
 
 
-        size:=def_cgsize(left.resultdef);
+        size:=def_cgsize(resultdef);
 
 
         current_asmdata.getjumplabel(hl);
         current_asmdata.getjumplabel(hl);
         cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,size,OC_GTE,0,left.location.register,hl);
         cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,size,OC_GTE,0,left.location.register,hl);
         cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,size,left.location.register,location.register);
         cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,size,left.location.register,location.register);
 
 
+        if cs_check_overflow in current_settings.localswitches then
+          cg.g_overflowcheck(current_asmdata.CurrAsmList,dummyloc,resultdef);
+
         cg.a_label(current_asmdata.CurrAsmList,hl);
         cg.a_label(current_asmdata.CurrAsmList,hl);
       end;
       end;