瀏覽代碼

* treat "u32bit-u32bit" as a signed value when removing automatic
64 bit upcasts, as the result can be negative when evaluated in
64 bit (reported on irc, please file bug reports)

git-svn-id: trunk@27725 -

Jonas Maebe 11 年之前
父節點
當前提交
e704dd8d74
共有 3 個文件被更改,包括 23 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ncnv.pas
  3. 17 0
      tests/tbs/tb0607.pp

+ 1 - 0
.gitattributes

@@ -10213,6 +10213,7 @@ tests/tbs/tb0603.pp svneol=native#text/pascal
 tests/tbs/tb0604.pp svneol=native#text/pascal
 tests/tbs/tb0605.pp svneol=native#text/pascal
 tests/tbs/tb0606.pp svneol=native#text/pascal
+tests/tbs/tb0607.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tbs0594.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain

+ 5 - 1
compiler/ncnv.pas

@@ -2500,7 +2500,11 @@ implementation
                 {  also done otherwise so there is no difference   }
                 {  in overload choosing etc between $r+ and $r-)   }
                 if (nf_internal in n.flags) then
-                  result:=true
+                  begin
+                    result:=true;
+                    { the result could be negative in this case }
+                    gotsint:=true
+                  end
                 else
                   result:=
                     docheckremove64bittypeconvs(tbinarynode(n).left) and

+ 17 - 0
tests/tbs/tb0607.pp

@@ -0,0 +1,17 @@
+{ %opt=-O2 }
+
+var
+  a,b: longword;
+  i: int64;
+  l1, l2: longword;
+begin
+  a:=1;
+  b:=123456;
+  i:= (a-b) div 10;
+  l1:=longword(i);
+  l2:=longword((a-b) div 10);
+  writeln(l1);
+  writeln(l2);
+  if l1<>l2 then
+    halt(1);
+end.