Ver Fonte

* don't look at the resultdef, but at the defs of the operands to decide
whether a multiplication needs to be signed or unsigned (can be different
in case of a 32x32->64 multiplication) (mantis #30035)

git-svn-id: trunk@33539 -

Jonas Maebe há 9 anos atrás
pai
commit
1850cb4ccc
4 ficheiros alterados com 32 adições e 1 exclusões
  1. 2 0
      .gitattributes
  2. 2 1
      compiler/powerpc/nppcadd.pas
  3. 14 0
      tests/webtbs/tw30035.pp
  4. 14 0
      tests/webtbs/tw30035a.pp

+ 2 - 0
.gitattributes

@@ -15013,6 +15013,8 @@ tests/webtbs/tw29958.pp svneol=native#text/pascal
 tests/webtbs/tw2998.pp svneol=native#text/plain
 tests/webtbs/tw2999.pp svneol=native#text/plain
 tests/webtbs/tw29992.pp svneol=native#text/plain
+tests/webtbs/tw30035.pp svneol=native#text/plain
+tests/webtbs/tw30035a.pp svneol=native#text/plain
 tests/webtbs/tw3004.pp svneol=native#text/plain
 tests/webtbs/tw3005.pp svneol=native#text/plain
 tests/webtbs/tw3010.pp svneol=native#text/plain

+ 2 - 1
compiler/powerpc/nppcadd.pas

@@ -485,7 +485,8 @@ interface
           end
         else
           begin
-            if is_signed(resultdef) then
+            if is_signed(left.resultdef) and
+               is_signed(right.resultdef) then
               begin
                 case nodetype of
                   addn:

+ 14 - 0
tests/webtbs/tw30035.pp

@@ -0,0 +1,14 @@
+var
+  i64: Int64;
+  qa, qb: DWord;
+begin
+  qa := 2147483648;
+  qb := 536870912;
+{$R-}{$Q-}
+  i64 := int64(qa) * int64(qb);
+  if i64 <> 1152921504606846976 then
+  begin
+    Writeln('Error!');
+    Halt(1);
+  end;
+end.

+ 14 - 0
tests/webtbs/tw30035a.pp

@@ -0,0 +1,14 @@
+var
+  i64: Int64;
+  qa, qb: DWord;
+begin
+  qa := 2147483648;
+  qb := 536870912;
+{$R+}{$Q+}
+  i64 := int64(qa) * int64(qb);
+  if i64 <> 1152921504606846976 then
+  begin
+    Writeln('Error!');
+    Halt(1);
+  end;
+end.