* when optimizing temp assignments by simply replacing one temp with

another, it's not enough that the temp sizes are the same, because
    the assignment may only apply to part of them. In such cases,
    perform a regular copy (mantis #13948)

git-svn-id: trunk@13255 -
This commit is contained in:
Jonas Maebe 2009-06-10 19:14:40 +00:00
parent 4a2acd9d87
commit 5c4f80d6bc
3 changed files with 40 additions and 0 deletions

1
.gitattributes vendored
View File

@ -9158,6 +9158,7 @@ tests/webtbs/tw13763.pp svneol=native#text/plain
tests/webtbs/tw13813.pp svneol=native#text/plain
tests/webtbs/tw13820.pp svneol=native#text/plain
tests/webtbs/tw13890.pp svneol=native#text/plain
tests/webtbs/tw13948.pp svneol=native#text/plain
tests/webtbs/tw1398.pp svneol=native#text/plain
tests/webtbs/tw1401.pp svneol=native#text/plain
tests/webtbs/tw1407.pp svneol=native#text/plain

View File

@ -116,6 +116,14 @@ implementation
result := fen_norecurse_true;
end;
end;
{ Subscriptn must be rejected, otherwise we may replace an
an entire record with a temp for its first field, mantis #13948)
Exception: the field's size is the same as the entire record
}
subscriptn:
if not(tsubscriptnode(n).left.resultdef.typ in [recorddef,objectdef]) or
(tsubscriptnode(n).left.resultdef.size <> tsubscriptnode(n).resultdef.size) then
result := fen_norecurse_false;
{ optimize the searching a bit }
derefn,addrn,
calln,inlinen,casen,

31
tests/webtbs/tw13948.pp Normal file
View File

@ -0,0 +1,31 @@
{ %opt=-O2 }
type
tr = record
a,b: longint;
end;
function f: tr;
begin
f.a:=5;
f.b:=6;
end;
procedure test;
var
r: tr;
begin
r.a:=1;
r.b:=2;
r.a:=f.a;
writeln(r.a);
writeln(r.b);
if (r.a<>5) then
halt(1);
if (r.b<>2) then
halt(2);
end;
begin
test;
end.