Browse Source

* fixed range checking of cardinal constants
* fixed range checking of "qword constants" (they don't really exist,
but values > high(int64) were set to zero if assigned to qword)

Jonas Maebe 25 years ago
parent
commit
4b7aa484f1
1 changed files with 12 additions and 4 deletions
  1. 12 4
      compiler/types.pas

+ 12 - 4
compiler/types.pas

@@ -776,7 +776,9 @@ implementation
            begin
            begin
               if (l<0) and (porddef(def)^.typ=u64bit) then
               if (l<0) and (porddef(def)^.typ=u64bit) then
                 begin
                 begin
-                   l:=0;
+                   { don't zero the result, because it may come from hex notation 
+                     like $ffffffffffffffff! (JM)
+                   l:=0; }
                    if (cs_check_range in aktlocalswitches) then
                    if (cs_check_range in aktlocalswitches) then
                      Message(parser_e_range_check_error)
                      Message(parser_e_range_check_error)
                    else
                    else
@@ -805,9 +807,10 @@ implementation
                      { this happens with the wrap around problem  }
                      { this happens with the wrap around problem  }
                      { if lv is positive and hv is over $7ffffff  }
                      { if lv is positive and hv is over $7ffffff  }
                      { so it seems negative                       }
                      { so it seems negative                       }
+                     { fix with typecasts (JM) }
                      begin
                      begin
-                        if ((l>=0) and (l<lv)) or
-                           ((l<0) and (l>hv)) then
+                        if (l < cardinal(lv)) or
+                           (l > cardinal(hv)) then
                           begin
                           begin
                              if (cs_check_range in aktlocalswitches) then
                              if (cs_check_range in aktlocalswitches) then
                                Message(parser_e_range_check_error)
                                Message(parser_e_range_check_error)
@@ -1737,7 +1740,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.25  2000-12-08 14:06:11  jonas
+  Revision 1.26  2000-12-11 19:13:54  jonas
+    * fixed range checking of cardinal constants
+    * fixed range checking of "qword constants" (they don't really exist,
+      but values > high(int64) were set to zero if assigned to qword)
+
+  Revision 1.25  2000/12/08 14:06:11  jonas
     * fix for web bug 1245: arrays of char with size >255 are now passed to
     * fix for web bug 1245: arrays of char with size >255 are now passed to
       overloaded procedures which expect ansistrings instead of shortstrings
       overloaded procedures which expect ansistrings instead of shortstrings
       if possible
       if possible