mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 02:28:22 +02:00
* taking the address of an absolute var sym with constant address evaluates into a const. pointer, resolves #17118
git-svn-id: trunk@15723 -
This commit is contained in:
parent
aa681f5e11
commit
683ac0ea45
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10585,6 +10585,7 @@ tests/webtbs/tw16954.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1696.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1699.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1709.pp svneol=native#text/plain
|
||||
tests/webtbs/tw17118.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1720.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1735.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1737.pp svneol=native#text/plain
|
||||
|
@ -499,7 +499,20 @@ implementation
|
||||
end
|
||||
else
|
||||
{$endif i386}
|
||||
if (nf_internal in flags) or
|
||||
if (hp.nodetype=loadn) and
|
||||
(tloadnode(hp).symtableentry.typ=absolutevarsym) and
|
||||
{$ifdef i386}
|
||||
not(tabsolutevarsym(tloadnode(hp).symtableentry).absseg) and
|
||||
{$endif i386}
|
||||
(tabsolutevarsym(tloadnode(hp).symtableentry).abstyp=toaddr) then
|
||||
begin
|
||||
if nf_typedaddr in flags then
|
||||
result:=cpointerconstnode.create(tabsolutevarsym(tloadnode(hp).symtableentry).addroffset,tpointerdef.create(left.resultdef))
|
||||
else
|
||||
result:=cpointerconstnode.create(tabsolutevarsym(tloadnode(hp).symtableentry).addroffset,voidpointertype);
|
||||
exit;
|
||||
end
|
||||
else if (nf_internal in flags) or
|
||||
valid_for_addr(left,true) then
|
||||
begin
|
||||
if not(nf_typedaddr in flags) then
|
||||
|
19
tests/webtbs/tw17118.pp
Normal file
19
tests/webtbs/tw17118.pp
Normal file
@ -0,0 +1,19 @@
|
||||
type
|
||||
TRecord = record
|
||||
P1,
|
||||
P2: pointer;
|
||||
end;
|
||||
|
||||
var
|
||||
var1: longint;
|
||||
varabs: longint absolute 1234;
|
||||
const
|
||||
info: TRecord = (P1: @var1; // Works
|
||||
P2: @varabs); // Won't work
|
||||
|
||||
begin
|
||||
if ptrint(info.p2)<>1234 then
|
||||
halt(1);
|
||||
writeln('ok');
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user