mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 11:59:19 +02:00
* don't write rtti for static fields so we don't try to initialise/finalise
them (mantis #17546) * fixed the various field rtti methods so that they only operate on fields and skip the rest (at the end they always typecast the sym to a tfieldvarsym, so this could result in wrong memory accesses) git-svn-id: trunk@16086 -
This commit is contained in:
parent
747a5c804b
commit
13399280dc
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10689,6 +10689,7 @@ tests/webtbs/tw17402a.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw17413.pp svneol=native#text/plain
|
tests/webtbs/tw17413.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw17430.pp svneol=native#text/plain
|
tests/webtbs/tw17430.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1744.pp svneol=native#text/plain
|
tests/webtbs/tw1744.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw17546.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
|
||||||
tests/webtbs/tw1758.pp svneol=native#text/plain
|
tests/webtbs/tw1758.pp svneol=native#text/plain
|
||||||
|
@ -121,9 +121,10 @@ implementation
|
|||||||
for i:=0 to st.SymList.Count-1 do
|
for i:=0 to st.SymList.Count-1 do
|
||||||
begin
|
begin
|
||||||
sym:=tsym(st.SymList[i]);
|
sym:=tsym(st.SymList[i]);
|
||||||
if (rt=fullrtti) or
|
if (tsym(sym).typ=fieldvarsym) and
|
||||||
|
not(sp_static in tsym(sym).symoptions) and
|
||||||
(
|
(
|
||||||
(tsym(sym).typ=fieldvarsym) and
|
(rt=fullrtti) or
|
||||||
tfieldvarsym(sym).vardef.needs_inittable
|
tfieldvarsym(sym).vardef.needs_inittable
|
||||||
) then
|
) then
|
||||||
inc(result);
|
inc(result);
|
||||||
@ -139,9 +140,10 @@ implementation
|
|||||||
for i:=0 to st.SymList.Count-1 do
|
for i:=0 to st.SymList.Count-1 do
|
||||||
begin
|
begin
|
||||||
sym:=tsym(st.SymList[i]);
|
sym:=tsym(st.SymList[i]);
|
||||||
if (rt=fullrtti) or
|
if (tsym(sym).typ=fieldvarsym) and
|
||||||
|
not(sp_static in tsym(sym).symoptions) and
|
||||||
(
|
(
|
||||||
(tsym(sym).typ=fieldvarsym) and
|
(rt=fullrtti) or
|
||||||
tfieldvarsym(sym).vardef.needs_inittable
|
tfieldvarsym(sym).vardef.needs_inittable
|
||||||
) then
|
) then
|
||||||
begin
|
begin
|
||||||
@ -160,9 +162,10 @@ implementation
|
|||||||
for i:=0 to st.SymList.Count-1 do
|
for i:=0 to st.SymList.Count-1 do
|
||||||
begin
|
begin
|
||||||
sym:=tsym(st.SymList[i]);
|
sym:=tsym(st.SymList[i]);
|
||||||
if (rt=fullrtti) or
|
if (tsym(sym).typ=fieldvarsym) and
|
||||||
|
not(sp_static in tsym(sym).symoptions) and
|
||||||
(
|
(
|
||||||
(tsym(sym).typ=fieldvarsym) and
|
(rt=fullrtti) or
|
||||||
tfieldvarsym(sym).vardef.needs_inittable
|
tfieldvarsym(sym).vardef.needs_inittable
|
||||||
) then
|
) then
|
||||||
write_rtti(tfieldvarsym(sym).vardef,rt);
|
write_rtti(tfieldvarsym(sym).vardef,rt);
|
||||||
|
28
tests/webtbs/tw17546.pp
Normal file
28
tests/webtbs/tw17546.pp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{ %opt=-gh }
|
||||||
|
|
||||||
|
{$MODE OBJFPC}
|
||||||
|
|
||||||
|
program test02;
|
||||||
|
|
||||||
|
{$STATIC ON}
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
TDummyClass = class
|
||||||
|
IdName: AnsiString; static;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
|
||||||
|
o: TDummyClass;
|
||||||
|
|
||||||
|
begin
|
||||||
|
HaltOnNotReleased := true;
|
||||||
|
TDummyClass.IdName := 'Test';
|
||||||
|
TDummyClass.IdName := TDummyClass.IdName + 'a';
|
||||||
|
o := TDummyClass.Create;
|
||||||
|
WriteLn('Here we go');
|
||||||
|
o.Free;
|
||||||
|
WriteLn('We did it!');
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user