Browse Source

* fix J. Gareth Moreton to resolve #36389

git-svn-id: trunk@43670 -
florian 5 years ago
parent
commit
ef7e4f6f62
3 changed files with 25 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/x86/aoptx86.pas
  3. 22 0
      tests/webtbs/tw36389.pp

+ 1 - 0
.gitattributes

@@ -17891,6 +17891,7 @@ tests/webtbs/tw36215.pp svneol=native#text/pascal
 tests/webtbs/tw3628.pp svneol=native#text/plain
 tests/webtbs/tw3634.pp svneol=native#text/plain
 tests/webtbs/tw36388.pp svneol=native#text/pascal
+tests/webtbs/tw36389.pp svneol=native#text/pascal
 tests/webtbs/tw3650.pp svneol=native#text/plain
 tests/webtbs/tw3653.pp svneol=native#text/plain
 tests/webtbs/tw3661.pp svneol=native#text/plain

+ 2 - 2
compiler/x86/aoptx86.pas

@@ -2247,8 +2247,8 @@ unit aoptx86;
                           debug_op2str(taicpu(hp2).opcode)+debug_opsize2str(taicpu(hp2).opsize)+')',p);
                     { limit size of constants as well to avoid assembler errors, but
                       check opsize to avoid overflow when left shifting the 1 }
-                    if (taicpu(p).oper[0]^.typ=top_const) and (topsize2memsize[taicpu(hp2).opsize]<=4) then
-                      taicpu(p).oper[0]^.val:=taicpu(p).oper[0]^.val and ((qword(1) shl (topsize2memsize[taicpu(hp2).opsize]*8))-1);
+                    if (taicpu(p).oper[0]^.typ=top_const) and (topsize2memsize[taicpu(hp2).opsize]<=63) then
+                      taicpu(p).oper[0]^.val:=taicpu(p).oper[0]^.val and ((qword(1) shl topsize2memsize[taicpu(hp2).opsize])-1);
                     taicpu(hp1).changeopsize(taicpu(hp2).opsize);
                     taicpu(p).changeopsize(taicpu(hp2).opsize);
                     if taicpu(p).oper[0]^.typ=top_reg then

+ 22 - 0
tests/webtbs/tw36389.pp

@@ -0,0 +1,22 @@
+{$inline on}
+{$mode objfpc}
+function Correct(TempInt: integer; Value: word): word; inline;
+begin
+ if TempInt = 32768 then
+   Result := Value - TempInt
+  else
+   Result := 65536 - Value;
+end;
+
+procedure p;
+var
+ Arr: array of word;
+ Temp: integer;
+begin
+ SetLength(Arr,1);
+ Temp:= 42;
+ Arr[0] := Correct(Temp, Arr[0]);
+end; 
+
+begin
+end.