* better error recovery, resolves #39485

This commit is contained in:
florian 2021-12-16 22:27:18 +01:00
parent d5b368988f
commit c6874df5c8
2 changed files with 40 additions and 5 deletions

View File

@ -165,6 +165,8 @@ implementation
procedure struct_property_dec(is_classproperty:boolean;var rtti_attrs_def: trtti_attribute_list);
var
p : tpropertysym;
_deprecatedmsg: pshortstring;
_symoptions: tsymoptions;
begin
{ check for a class, record or helper }
if not((is_class_or_interface_or_dispinterface(current_structdef) or is_record(current_structdef) or
@ -214,12 +216,25 @@ implementation
Message(parser_e_enumerator_identifier_required);
consume(_SEMICOLON);
end;
trtti_attribute_list.bind(rtti_attrs_def,p.rtti_attribute_list);
{ in case of a previous error, p might not be assigned }
if assigned(p) then
begin
trtti_attribute_list.bind(rtti_attrs_def,p.rtti_attribute_list);
{ hint directives, these can be separated by semicolons here,
that needs to be handled here with a loop (PFV) }
while try_consume_hintdirective(p.symoptions,p.deprecatedmsg) do
Consume(_SEMICOLON);
{ hint directives, these can be separated by semicolons here,
that needs to be handled here with a loop (PFV) }
while try_consume_hintdirective(p.symoptions,p.deprecatedmsg) do
Consume(_SEMICOLON);
end
else
begin
{ recover from error so we can continue to parse }
{ hint directives, these can be separated by semicolons here,
that needs to be handled here with a loop (PFV) }
while try_consume_hintdirective(_symoptions,_deprecatedmsg) do
Consume(_SEMICOLON);
end;
end;

20
tests/tbf/tw39485.pp Normal file
View File

@ -0,0 +1,20 @@
{ %fail }
program Project1;
{$mode objfpc}{$H+}{$Interfaces CORBA}
type
ITest = interface
end;
TBar = class;
TFoo = class(TObject, ITest)
Fa: TBar;
property a: TBar read Fa implements ITest;
end;
TBar = class(TObject, ITest)
end;
begin
end.