Explorar el Código

* always demote type conversions which cannot represent part of the
source value to convert_l3, instead of only those with a destination
type whose size is < source size (like Delphi) + test -> fixes
toperator6 along with a host of wrong tordconst typeconversions in
the compiler sources themselves (although most are harmless)

git-svn-id: trunk@8323 -

Jonas Maebe hace 18 años
padre
commit
5bc156efea
Se han modificado 3 ficheros con 27 adiciones y 5 borrados
  1. 1 0
      .gitattributes
  2. 3 5
      compiler/defcmp.pas
  3. 23 0
      tests/test/tover3.pp

+ 1 - 0
.gitattributes

@@ -6938,6 +6938,7 @@ tests/test/toperator5.pp svneol=native#text/plain
 tests/test/toperator6.pp svneol=native#text/plain
 tests/test/tover1.pp svneol=native#text/plain
 tests/test/tover2.pp svneol=native#text/plain
+tests/test/tover3.pp svneol=native#text/plain
 tests/test/tpackrec.pp svneol=native#text/plain
 tests/test/tpara1.pp svneol=native#text/plain
 tests/test/tpara2.pp svneol=native#text/plain

+ 3 - 5
compiler/defcmp.pas

@@ -250,12 +250,10 @@ implementation
                          doconv:=basedefconvertsimplicit[basedeftbl[torddef(def_from).ordtype],basedeftbl[torddef(def_to).ordtype]];
                         if (doconv=tc_not_possible) then
                           eq:=te_incompatible
-                        else
+                        else if (not is_in_limit(def_from,def_to)) then
                           { "punish" bad type conversions :) (JM) }
-                          if (not is_in_limit(def_from,def_to)) and
-                             (def_from.size > def_to.size) then
-                            eq:=te_convert_l3
-                        else
+                          eq:=te_convert_l3
+                         else
                           eq:=te_convert_l1;
                       end;
                    end;

+ 23 - 0
tests/test/tover3.pp

@@ -0,0 +1,23 @@
+{ %fail }
+
+procedure t1(l: longint); overload;
+begin
+  writeln('longint');
+end;
+
+procedure t1(l: smallint); overload;
+begin
+  writeln('smallint');
+end;
+
+procedure t1(l: word); overload;
+begin
+  writeln('word');
+end;
+
+var
+  c: cardinal;
+begin
+  c:=1;
+  t1(c);
+end.