* Fixed r43577 for cases when the size of the new result of a simplified node after typecheckpass is smaller than the size of the original node's result. This caused internal errors or invalid assembly in some cases. Issue #36587.

git-svn-id: trunk@44151 -
This commit is contained in:
yury 2020-02-11 12:49:12 +00:00
parent 44455d0ea4
commit 39c48f0d01
3 changed files with 51 additions and 12 deletions

1
.gitattributes vendored
View File

@ -18029,6 +18029,7 @@ tests/webtbs/tw3650.pp svneol=native#text/plain
tests/webtbs/tw3653.pp svneol=native#text/plain
tests/webtbs/tw36544a.pp svneol=native#text/pascal
tests/webtbs/tw36544b.pp svneol=native#text/pascal
tests/webtbs/tw36587.pp svneol=native#text/plain
tests/webtbs/tw36589.pp svneol=native#text/pascal
tests/webtbs/tw3661.pp svneol=native#text/plain
tests/webtbs/tw3666.pp svneol=native#text/plain

View File

@ -476,6 +476,18 @@ implementation
end;
function GetCopyAndTypeCheck: tnode;
begin
result:=getcopy;
result.resultdef:=nil;
do_typecheckpass(result);
{ If the size of the new result after typecheckpass is smaller than
the size of the original result, use the original (bigger) size. }
if result.resultdef.size < resultdef.size then
result.resultdef:=resultdef;
end;
var
t , vl, hp: tnode;
lt,rt : tnodetype;
@ -750,9 +762,7 @@ implementation
right:=taddnode(left).right;
taddnode(left).right:=hp;
left:=left.simplify(false);
result:=getcopy;
result.resultdef:=nil;
do_typecheckpass(result);
result:=GetCopyAndTypeCheck;
end;
else
;
@ -771,9 +781,7 @@ implementation
right:=taddnode(left).left;
taddnode(left).left:=hp;
left:=left.simplify(false);
result:=getcopy;
result.resultdef:=nil;
do_typecheckpass(result);
result:=GetCopyAndTypeCheck;
end;
else
;
@ -842,9 +850,7 @@ implementation
left:=taddnode(right).right;
taddnode(right).right:=hp;
right:=right.simplify(false);
result:=getcopy;
result.resultdef:=nil;
do_typecheckpass(result);
result:=GetCopyAndTypeCheck;
end;
else
;
@ -863,9 +869,7 @@ implementation
left:=taddnode(right).left;
taddnode(right).left:=hp;
right:=right.simplify(false);
result:=getcopy;
result.resultdef:=nil;
do_typecheckpass(result);
result:=GetCopyAndTypeCheck;
end;
else
;

34
tests/webtbs/tw36587.pp Normal file
View File

@ -0,0 +1,34 @@
const
A1 = 1000000;
B1 = 60;
C1 = 6000000;
T1 = A1*B1;
T2 = A1*C1;
procedure dotest(P: longint);
var
i64: Int64;
begin
i64 := 0;
i64 := i64 + P * B1 * int64(A1);
writeln(i64);
if i64 <> P*int64(T1) then
Halt(1);
i64 := 0;
i64 := i64 + P * B1 * A1;
writeln(i64);
if i64 <> P*T1 then
Halt(2);
i64 := 0;
i64 := i64 + P * C1 * A1;
writeln(i64);
if i64 <> P*T2 then
Halt(3);
end;
begin
dotest(1000000);
writeln('OK.');
end.