Browse Source

* make integer division instruction (div/idiv) on x86 dependent on the
resulttype of the div node set by the type checking pass, this is
also how the generic code generator handles it, resolves #27173

git-svn-id: trunk@29382 -

florian 10 years ago
parent
commit
29d4037a9c
3 changed files with 19 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/x86/nx86mat.pas
  3. 16 0
      tests/webtbs/tw27173.pp

+ 1 - 0
.gitattributes

@@ -14173,6 +14173,7 @@ tests/webtbs/tw2710.pp svneol=native#text/plain
 tests/webtbs/tw27120.pp svneol=native#text/pascal
 tests/webtbs/tw2713.pp svneol=native#text/plain
 tests/webtbs/tw27153.pp svneol=native#text/pascal
+tests/webtbs/tw27173.pp svneol=native#text/pascal
 tests/webtbs/tw27185.pp svneol=native#text/pascal
 tests/webtbs/tw2721.pp svneol=native#text/plain
 tests/webtbs/tw2723.pp svneol=native#text/plain

+ 2 - 2
compiler/x86/nx86mat.pas

@@ -527,8 +527,8 @@ interface
             else
               emit_reg_reg(A_XOR,opsize,regd,regd);
 
-            {Division depends on the right type.}
-            if is_signed(right.resultdef) then
+            { Division depends on the result type }
+            if is_signed(resultdef) then
               op:=A_IDIV
             else
               op:=A_DIV;

+ 16 - 0
tests/webtbs/tw27173.pp

@@ -0,0 +1,16 @@
+program error;
+
+{$mode Delphi}
+
+uses sysutils;
+
+type a = 1..MaxInt;
+
+var b: a;
+    c: integer;
+
+begin
+ b := 3;
+ c := -5 div b;
+ writeln(c);
+end.