Browse Source

* also give a "potential range error" hint with -CO in case the sizes
match but the source range does not fit in the dest range
(related to mantis #16023)
* don't give a "potential range error" when converting between
s80real and sc80real, since even though the size may differ,
the represented range does not

git-svn-id: trunk@15044 -

Jonas Maebe 15 years ago
parent
commit
653974f679
3 changed files with 20 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 9 1
      compiler/htypechk.pas
  3. 10 0
      tests/webtbf/tw16203.pp

+ 1 - 0
.gitattributes

@@ -9649,6 +9649,7 @@ tests/webtbf/tw15777b.pp svneol=native#text/plain
 tests/webtbf/tw1599.pp svneol=native#text/plain
 tests/webtbf/tw1599.pp svneol=native#text/plain
 tests/webtbf/tw1599b.pp svneol=native#text/plain
 tests/webtbf/tw1599b.pp svneol=native#text/plain
 tests/webtbf/tw16022.pp svneol=native#text/plain
 tests/webtbf/tw16022.pp svneol=native#text/plain
+tests/webtbf/tw16203.pp svneol=native#text/plain
 tests/webtbf/tw1633.pp svneol=native#text/plain
 tests/webtbf/tw1633.pp svneol=native#text/plain
 tests/webtbf/tw1642.pp svneol=native#text/plain
 tests/webtbf/tw1642.pp svneol=native#text/plain
 tests/webtbf/tw1655.pp svneol=native#text/plain
 tests/webtbf/tw1655.pp svneol=native#text/plain

+ 9 - 1
compiler/htypechk.pas

@@ -2708,7 +2708,15 @@ implementation
           not is_boolean(source.resultdef) and
           not is_boolean(source.resultdef) and
           not is_constrealnode(source) then
           not is_constrealnode(source) then
          begin
          begin
-           if (destdef.size < source.resultdef.size) then
+           if ((destdef.size < source.resultdef.size) and
+               { s80real and sc80real have a different size but the same precision }
+               not((destdef.typ=floatdef) and
+                   (source.resultdef.typ=floatdef) and
+                   (tfloatdef(source.resultdef).floattype in [s80real,sc80real]) and
+                   (tfloatdef(destdef).floattype in [s80real,sc80real]))) or
+              ((destdef.typ<>floatdef) and
+               (source.resultdef.typ<>floatdef) and
+               not is_in_limit(source.resultdef,destdef)) then
              begin
              begin
                if (cs_check_range in current_settings.localswitches) then
                if (cs_check_range in current_settings.localswitches) then
                  MessagePos(location,type_w_smaller_possible_range_check)
                  MessagePos(location,type_w_smaller_possible_range_check)

+ 10 - 0
tests/webtbf/tw16203.pp

@@ -0,0 +1,10 @@
+{ %OPT=-vh -Seh }
+{ %fail }
+
+var
+  B : Byte;
+  s: shortint;
+begin
+  b:=255;
+  s:=b;
+end.