mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 22:40:45 +01:00
* don't perform temp substitution for variables whose address has been taken
or that are accessible outside the current block (mantis #17413) git-svn-id: trunk@15990 -
This commit is contained in:
parent
7a6b26f6e2
commit
ac8add7cf9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10654,6 +10654,7 @@ tests/webtbs/tw1735.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw1737.pp svneol=native#text/plain
|
tests/webtbs/tw1737.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw17379.pp svneol=native#text/plain
|
tests/webtbs/tw17379.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw17379a.pp svneol=native#text/plain
|
tests/webtbs/tw17379a.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw17413.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1744.pp svneol=native#text/plain
|
tests/webtbs/tw1744.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1754c.pp svneol=native#text/plain
|
tests/webtbs/tw1754c.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1755.pp svneol=native#text/plain
|
tests/webtbs/tw1755.pp svneol=native#text/plain
|
||||||
|
|||||||
@ -96,7 +96,9 @@ implementation
|
|||||||
{ stored in memory... }
|
{ stored in memory... }
|
||||||
(tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.loc in [LOC_REFERENCE]) and
|
(tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.loc in [LOC_REFERENCE]) and
|
||||||
{ ... at the place we are looking for }
|
{ ... at the place we are looking for }
|
||||||
references_equal(tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.reference,rr^.old^) then
|
references_equal(tabstractnormalvarsym(tloadnode(n).symtableentry).localloc.reference,rr^.old^) and
|
||||||
|
{ its address cannot have escaped the current routine }
|
||||||
|
not(tabstractvarsym(tloadnode(n).symtableentry).addr_taken) then
|
||||||
begin
|
begin
|
||||||
{ relocate variable }
|
{ relocate variable }
|
||||||
tcgloadnode(n).changereflocation(rr^.new^);
|
tcgloadnode(n).changereflocation(rr^.new^);
|
||||||
@ -109,7 +111,9 @@ implementation
|
|||||||
{ memory temp... }
|
{ memory temp... }
|
||||||
(ttemprefnode(n).tempinfo^.location.loc in [LOC_REFERENCE]) and
|
(ttemprefnode(n).tempinfo^.location.loc in [LOC_REFERENCE]) and
|
||||||
{ ... at the place we are looking for }
|
{ ... at the place we are looking for }
|
||||||
references_equal(ttemprefnode(n).tempinfo^.location.reference,rr^.old^) then
|
references_equal(ttemprefnode(n).tempinfo^.location.reference,rr^.old^) and
|
||||||
|
{ its address cannot have escaped the current routine }
|
||||||
|
not(ti_addr_taken in ttemprefnode(n).tempinfo^.flags) then
|
||||||
begin
|
begin
|
||||||
{ relocate the temp }
|
{ relocate the temp }
|
||||||
tcgtemprefnode(n).changelocation(rr^.new^);
|
tcgtemprefnode(n).changelocation(rr^.new^);
|
||||||
|
|||||||
48
tests/webtbs/tw17413.pp
Normal file
48
tests/webtbs/tw17413.pp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{$mode objfpc}
|
||||||
|
{$H+}
|
||||||
|
|
||||||
|
uses SysUtils;
|
||||||
|
|
||||||
|
type
|
||||||
|
TVector3Single = array [0..2] of Single;
|
||||||
|
|
||||||
|
function Vector3Single(const X, Y, Z: Single): TVector3Single;
|
||||||
|
begin
|
||||||
|
Result[0] := X;
|
||||||
|
Result[1] := Y;
|
||||||
|
Result[2] := Z;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
res1, res2, res3: single;
|
||||||
|
|
||||||
|
procedure RenderFromViewEverything;
|
||||||
|
var
|
||||||
|
Normal: TVector3Single;
|
||||||
|
|
||||||
|
procedure DoTexCoordVertex(const Vertex: TVector3Single);
|
||||||
|
begin
|
||||||
|
Writeln('Normal: ', Normal[0]:1:1, ' ', Normal[1]:1:1, ' ', Normal[2]:1:1);
|
||||||
|
if (normal[0]<>res1) or
|
||||||
|
(normal[1]<>res2) or
|
||||||
|
(normal[2]<>res3) then
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
res1:=123;
|
||||||
|
res2:=456;
|
||||||
|
res3:=789;
|
||||||
|
Normal := Vector3Single(123, 456, 789);
|
||||||
|
DoTexCoordVertex(Vector3Single(111, 222, 333));
|
||||||
|
|
||||||
|
res1:=987;
|
||||||
|
res2:=654;
|
||||||
|
res3:=321;
|
||||||
|
Normal := Vector3Single(987, 654, 321);
|
||||||
|
DoTexCoordVertex(Vector3Single(444, 555, 666));
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
RenderFromViewEverything;
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user