* fixed crash when trying to index a record without a default property

git-svn-id: trunk@17480 -
This commit is contained in:
Jonas Maebe 2011-05-17 13:13:59 +00:00
parent 62ac6c23a0
commit b0e83a06af
4 changed files with 22 additions and 4 deletions

1
.gitattributes vendored
View File

@ -8390,6 +8390,7 @@ tests/tbf/tb0217.pp svneol=native#text/plain
tests/tbf/tb0218.pp svneol=native#text/plain
tests/tbf/tb0219.pp svneol=native#text/pascal
tests/tbf/tb0220.pp svneol=native#text/plain
tests/tbf/tb0221.pp svneol=native#text/plain
tests/tbf/ub0115.pp svneol=native#text/plain
tests/tbf/ub0149.pp svneol=native#text/plain
tests/tbf/ub0158a.pp svneol=native#text/plain

View File

@ -1930,7 +1930,7 @@ implementation
is_dispinterface(p1.resultdef) or is_record(p1.resultdef) then
begin
{ default property }
protsym:=search_default_property(tobjectdef(p1.resultdef));
protsym:=search_default_property(tabstractrecorddef(p1.resultdef));
if not(assigned(protsym)) then
begin
p1.destroy;

View File

@ -247,7 +247,7 @@ interface
function defined_macro(const s : string):boolean;
{*** Object Helpers ***}
function search_default_property(pd : tobjectdef) : tpropertysym;
function search_default_property(pd : tabstractrecorddef) : tpropertysym;
function find_real_objcclass_definition(pd: tobjectdef; erroronfailure: boolean): tobjectdef;
{*** Macro Helpers ***}
@ -2854,7 +2854,7 @@ implementation
Object Helpers
****************************************************************************}
function search_default_property(pd : tobjectdef) : tpropertysym;
function search_default_property(pd : tabstractrecorddef) : tpropertysym;
{ returns the default property of a class, searches also anchestors }
var
_defaultprop : tpropertysym;
@ -2881,7 +2881,10 @@ implementation
pd.symtable.SymList.ForEachCall(@tstoredsymtable(pd.symtable).testfordefaultproperty,@_defaultprop);
if assigned(_defaultprop) then
break;
pd:=pd.childof;
if (pd.typ=objectdef) then
pd:=tobjectdef(pd).childof
else
break;
end;
search_default_property:=_defaultprop;
end;

14
tests/tbf/tb0221.pp Normal file
View File

@ -0,0 +1,14 @@
{ %fail }
{ should not crash the compiler }
type
tr = record
a,b: longint;
end;
var
r: tr;
begin
r[0].a:=1;
end.