Browse Source

* fixes so no more range errors with improved range checking code

Jonas Maebe 25 years ago
parent
commit
4706eff850
5 changed files with 42 additions and 19 deletions
  1. 12 1
      compiler/cresstr.pas
  2. 6 3
      compiler/i386/n386con.pas
  3. 6 3
      compiler/i386/n386ld.pas
  4. 10 7
      compiler/i386/n386set.pas
  5. 8 5
      compiler/symsym.pas

+ 12 - 1
compiler/cresstr.pas

@@ -89,6 +89,10 @@ begin
   FreeMem(Value,Len);
 end;
 
+{$ifopt r+}
+{$define rangeon}
+{$r-}
+{$endif}
 
 procedure TResourceStringItem.CalcHash;
 Var
@@ -110,6 +114,10 @@ begin
     Hash:=Not(0);
 end;
 
+{$ifdef rangeon}
+{$r+}
+{$undef rangeon}
+{$endif}
 
 { ---------------------------------------------------------------------
                           TRESOURCESTRINGS
@@ -287,7 +295,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.6  2000-09-24 15:06:14  peter
+  Revision 1.7  2000-11-13 14:44:35  jonas
+    * fixes so no more range errors with improved range checking code
+
+  Revision 1.6  2000/09/24 15:06:14  peter
     * use defines.inc
 
   Revision 1.5  2000/08/27 16:11:50  peter

+ 6 - 3
compiler/i386/n386con.pas

@@ -187,8 +187,8 @@ implementation
               if (cs_create_smart in aktmoduleswitches) then
                 consts^.concat(new(pai_cut,init));
               consts^.concat(new(pai_label,init(l)));
-              consts^.concat(new(pai_const,init_32bit(lo(value))));
-              consts^.concat(new(pai_const,init_32bit(hi(value))));
+              consts^.concat(new(pai_const,init_32bit(longint(lo(value)))));
+              consts^.concat(new(pai_const,init_32bit(longint(hi(value)))));
               reset_reference(location.reference);
               location.reference.symbol:=l;
            end
@@ -488,7 +488,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2000-10-31 22:02:56  peter
+  Revision 1.3  2000-11-13 14:44:36  jonas
+    * fixes so no more range errors with improved range checking code
+
+  Revision 1.2  2000/10/31 22:02:56  peter
     * symtable splitted, no real code changes
 
   Revision 1.1  2000/10/15 09:33:31  peter

+ 6 - 3
compiler/i386/n386ld.pas

@@ -579,12 +579,12 @@ implementation
                                   if is_64bitint(right.resulttype) then
                                     begin
                                        emit_const_ref(A_MOV,opsize,
-                                         lo(tordconstnode(right).value),
+                                         longint(lo(tordconstnode(right).value)),
                                          newreference(left.location.reference));
                                        r:=newreference(left.location.reference);
                                        inc(r^.offset,4);
                                        emit_const_ref(A_MOV,opsize,
-                                         hi(tordconstnode(right).value),r);
+                                         longint(hi(tordconstnode(right).value)),r);
                                     end
                                   else
                                     begin
@@ -1050,7 +1050,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  2000-11-12 23:24:15  florian
+  Revision 1.8  2000-11-13 14:44:36  jonas
+    * fixes so no more range errors with improved range checking code
+
+  Revision 1.7  2000/11/12 23:24:15  florian
     * interfaces are basically running
 
   Revision 1.6  2000/11/11 22:59:20  florian

+ 10 - 7
compiler/i386/n386set.pas

@@ -606,9 +606,9 @@ implementation
                   if opsize=S_Q then
                     begin
                        getlabel(l1);
-                       emit_const_reg(A_CMP,S_L,hi(int64(t^._low)),hregister2);
+                       emit_const_reg(A_CMP,S_L,longint(hi(int64(t^._low))),hregister2);
                        emitjmp(C_NZ,l1);
-                       emit_const_reg(A_CMP,S_L,lo(int64(t^._low)),hregister);
+                       emit_const_reg(A_CMP,S_L,longint(lo(int64(t^._low))),hregister);
                        emitjmp(C_Z,t^.statement);
                        emitlab(l1);
                     end
@@ -629,10 +629,10 @@ implementation
                        if opsize=S_Q then
                          begin
                             getlabel(l1);
-                            emit_const_reg(A_CMP,S_L,hi(int64(t^._low)),hregister2);
+                            emit_const_reg(A_CMP,S_L,longint(hi(int64(t^._low))),hregister2);
                             emitjmp(jmp_le,elselabel);
                             emitjmp(jmp_gt,l1);
-                            emit_const_reg(A_CMP,S_L,lo(int64(t^._low)),hregister);
+                            emit_const_reg(A_CMP,S_L,longint(lo(int64(t^._low))),hregister);
                             { the comparisation of the low dword must be always unsigned! }
                             emitjmp(C_B,elselabel);
                             emitlab(l1);
@@ -647,10 +647,10 @@ implementation
                   if opsize=S_Q then
                     begin
                        getlabel(l1);
-                       emit_const_reg(A_CMP,S_L,hi(int64(t^._high)),hregister2);
+                       emit_const_reg(A_CMP,S_L,longint(hi(int64(t^._high))),hregister2);
                        emitjmp(jmp_le,t^.statement);
                        emitjmp(jmp_gt,l1);
-                       emit_const_reg(A_CMP,S_L,lo(int64(t^._high)),hregister);
+                       emit_const_reg(A_CMP,S_L,longint(lo(int64(t^._high))),hregister);
                        { the comparisation of the low dword must be always unsigned! }
                        emitjmp(C_BE,t^.statement);
                        emitlab(l1);
@@ -1061,7 +1061,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.3  2000-10-31 22:02:57  peter
+  Revision 1.4  2000-11-13 14:44:36  jonas
+    * fixes so no more range errors with improved range checking code
+
+  Revision 1.3  2000/10/31 22:02:57  peter
     * symtable splitted, no real code changes
 
   Revision 1.2  2000/10/26 15:53:27  jonas

+ 8 - 5
compiler/symsym.pas

@@ -2087,8 +2087,8 @@ implementation
            constint:
              if sizeof(TConstExprInt)=8 then
                begin
-                  writelong(lo(value));
-                  writelong(hi(value));
+                  writelong(longint(lo(value)));
+                  writelong(longint(hi(value)));
                end
              else
                writelong(value);
@@ -2102,8 +2102,8 @@ implementation
                consttype.write;
                if sizeof(TConstExprInt)=8 then
                  begin
-                    writelong(lo(value));
-                    writelong(hi(value));
+                    writelong(longint(lo(value)));
+                    writelong(longint(hi(value)));
                  end
                else
                  writelong(value);
@@ -2471,7 +2471,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.4  2000-11-08 23:15:17  florian
+  Revision 1.5  2000-11-13 14:44:35  jonas
+    * fixes so no more range errors with improved range checking code
+
+  Revision 1.4  2000/11/08 23:15:17  florian
     * tprocdef.procsym must be set also when a tprocdef is loaded from a PPU
 
   Revision 1.3  2000/11/06 23:13:53  peter