mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-09 21:49:18 +02:00
* fix for #39310 by fixing various small issues in tabstractrecordsymtable.has_single_field:
- initialize the returned def to a safe default - correctly reset the found symbol for each loop - reset the result when descending into a record + added test
This commit is contained in:
parent
d5d90499ee
commit
3ce6cae11d
@ -1633,6 +1633,7 @@ implementation
|
|||||||
sym: tfieldvarsym;
|
sym: tfieldvarsym;
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result:=false;
|
||||||
|
def:=generrordef;
|
||||||
{ If a record contains a union, it does not contain a "single
|
{ If a record contains a union, it does not contain a "single
|
||||||
non-composite field" in the context of certain ABIs requiring
|
non-composite field" in the context of certain ABIs requiring
|
||||||
special treatment for such records }
|
special treatment for such records }
|
||||||
@ -1642,8 +1643,8 @@ implementation
|
|||||||
{ a record/object can contain other things than fields }
|
{ a record/object can contain other things than fields }
|
||||||
currentsymlist:=symlist;
|
currentsymlist:=symlist;
|
||||||
{ recurse in arrays and records }
|
{ recurse in arrays and records }
|
||||||
sym:=nil;
|
|
||||||
repeat
|
repeat
|
||||||
|
sym:=nil;
|
||||||
{ record has one field? }
|
{ record has one field? }
|
||||||
for i:=0 to currentsymlist.Count-1 do
|
for i:=0 to currentsymlist.Count-1 do
|
||||||
begin
|
begin
|
||||||
@ -1674,7 +1675,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
{ if the array element is again a record, continue descending }
|
{ if the array element is again a record, continue descending }
|
||||||
if currentdef.typ=recorddef then
|
if currentdef.typ=recorddef then
|
||||||
|
begin
|
||||||
|
{ the record might be empty, so reset the result until we've
|
||||||
|
really found something }
|
||||||
|
result:=false;
|
||||||
currentsymlist:=trecorddef(currentdef).symtable.SymList
|
currentsymlist:=trecorddef(currentdef).symtable.SymList
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{ otherwise we found the type of the single element }
|
{ otherwise we found the type of the single element }
|
||||||
|
21
tests/webtbs/tw39310.pp
Normal file
21
tests/webtbs/tw39310.pp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{ %NORUN }
|
||||||
|
|
||||||
|
{$MODESWITCH ADVANCEDRECORDS}
|
||||||
|
Program tw39310;
|
||||||
|
|
||||||
|
Type
|
||||||
|
Rec0 = record
|
||||||
|
end;
|
||||||
|
|
||||||
|
Rec1 = record
|
||||||
|
r:Rec0;
|
||||||
|
Procedure Proc;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Procedure Rec1.Proc;
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
Begin
|
||||||
|
End.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user