mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 20:29:24 +02:00
* var, type, threadvar, const sections require also in classes etc. at least one declaration, resolves #39599
This commit is contained in:
parent
d36761f4a4
commit
9e3f647333
@ -1194,18 +1194,27 @@ implementation
|
|||||||
Message(parser_e_type_var_const_only_in_records_and_classes);
|
Message(parser_e_type_var_const_only_in_records_and_classes);
|
||||||
consume(_TYPE);
|
consume(_TYPE);
|
||||||
object_member_blocktype:=bt_type;
|
object_member_blocktype:=bt_type;
|
||||||
|
{ expect at least one type declaration }
|
||||||
|
if token<>_ID then
|
||||||
|
consume(_ID);
|
||||||
end;
|
end;
|
||||||
_VAR :
|
_VAR :
|
||||||
begin
|
begin
|
||||||
check_unbound_attributes;
|
check_unbound_attributes;
|
||||||
rtti_attrs_def := nil;
|
rtti_attrs_def := nil;
|
||||||
parse_var(false);
|
parse_var(false);
|
||||||
|
{ expect at least one var declaration }
|
||||||
|
if token<>_ID then
|
||||||
|
consume(_ID);
|
||||||
end;
|
end;
|
||||||
_CONST:
|
_CONST:
|
||||||
begin
|
begin
|
||||||
check_unbound_attributes;
|
check_unbound_attributes;
|
||||||
rtti_attrs_def := nil;
|
rtti_attrs_def := nil;
|
||||||
parse_const
|
parse_const;
|
||||||
|
{ expect at least one constant declaration }
|
||||||
|
if token<>_ID then
|
||||||
|
consume(_ID);
|
||||||
end;
|
end;
|
||||||
_THREADVAR :
|
_THREADVAR :
|
||||||
begin
|
begin
|
||||||
@ -1217,6 +1226,9 @@ implementation
|
|||||||
is_classdef:=true;
|
is_classdef:=true;
|
||||||
end;
|
end;
|
||||||
parse_var(true);
|
parse_var(true);
|
||||||
|
{ expect at least one threadvar declaration }
|
||||||
|
if token<>_ID then
|
||||||
|
consume(_ID);
|
||||||
end;
|
end;
|
||||||
_ID :
|
_ID :
|
||||||
begin
|
begin
|
||||||
|
10
tests/webtfs/tw39599a.pp
Normal file
10
tests/webtfs/tw39599a.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ %fail }
|
||||||
|
program project1;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
TMyClass = class(TObject)
|
||||||
|
const
|
||||||
|
procedure A; virtual; abstract; // should not be allowed
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
10
tests/webtfs/tw39599b.pp
Normal file
10
tests/webtfs/tw39599b.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ %fail }
|
||||||
|
program project1;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
TMyClass = class(TObject)
|
||||||
|
type
|
||||||
|
procedure A; virtual; abstract; // should not be allowed
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
10
tests/webtfs/tw39599c.pp
Normal file
10
tests/webtfs/tw39599c.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ %fail }
|
||||||
|
program project1;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
TMyClass = class(TObject)
|
||||||
|
var
|
||||||
|
procedure A; virtual; abstract; // should not be allowed
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
10
tests/webtfs/tw39599d.pp
Normal file
10
tests/webtfs/tw39599d.pp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ %fail }
|
||||||
|
program project1;
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
TMyClass = class(TObject)
|
||||||
|
threadvar
|
||||||
|
procedure A; virtual; abstract; // should not be allowed
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user