* do not allow constraints in headers of procedure implementations in delphi mode, resolves #36584

* better error message if a constraint is found at a wrong location

git-svn-id: trunk@44174 -
This commit is contained in:
florian 2020-02-14 20:56:55 +00:00
parent bde36ab7a0
commit b7afb2431c
7 changed files with 535 additions and 505 deletions

1
.gitattributes vendored
View File

@ -16226,6 +16226,7 @@ tests/webtbf/tw36397.pp -text svneol=native#text/pascal
tests/webtbf/tw3643.pp svneol=native#text/plain
tests/webtbf/tw3644.pp svneol=native#text/plain
tests/webtbf/tw36554.pp svneol=native#text/pascal
tests/webtbf/tw36584.pp svneol=native#text/pascal
tests/webtbf/tw3662.pp svneol=native#text/plain
tests/webtbf/tw36631a.pp svneol=native#text/pascal
tests/webtbf/tw36631b.pp svneol=native#text/pascal

View File

@ -436,7 +436,7 @@ scan_n_changecputype=02105_N_Changed CPU type to be consistent with specified co
#
# Parser
#
# 03354 is the last used one
# 03355 is the last used one
#
% \section{Parser messages}
% This section lists all parser messages. The parser takes care of the
@ -1609,6 +1609,9 @@ parser_w_enumeration_out_of_range=03353_W_Enumeration symbols can only have valu
parser_e_method_for_type_in_other_unit=03354_E_Implementing a method for type "$1" declared in another unit
% This error occurs if one tries to define a method for a type that is originally declared
% in a different unit.
parser_e_generic_constraints_not_allowed_here=03355_E_Generic constraint not allowed here
% At the current location specifying a constraint is not allowed. For example
% in delphi mode, a constraint might not be specified in the header of the implementation.
%
% \end{description}
%

View File

@ -465,6 +465,7 @@ const
parser_e_enumeration_out_of_range=03352;
parser_w_enumeration_out_of_range=03353;
parser_e_method_for_type_in_other_unit=03354;
parser_e_generic_constraints_not_allowed_here=03355;
type_e_mismatch=04000;
type_e_incompatible_types=04001;
type_e_not_equal_types=04002;
@ -1122,9 +1123,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 84622;
MsgTxtSize = 84666;
MsgIdxMax : array[1..20] of longint=(
28,106,355,127,99,63,143,35,223,68,
28,106,356,127,99,63,143,35,223,68,
62,20,30,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -664,7 +664,7 @@ implementation
message(type_e_type_id_expected)
else
begin
genericparams:=parse_generic_parameters(true);
genericparams:=parse_generic_parameters(not(m_delphi in current_settings.modeswitches) or parse_only);
if not assigned(genericparams) then
internalerror(2015061201);
if genericparams.count=0 then

View File

@ -1186,8 +1186,7 @@ uses
if try_to_consume(_COLON) then
begin
if not allowconstraints then
{ TODO }
Message(parser_e_illegal_expression{ parser_e_generic_constraints_not_allowed_here});
Message(parser_e_generic_constraints_not_allowed_here);
{ construct a name which can be used for a type specification }
constraintdata:=tgenericconstraintdata.create;
defname:='';

23
tests/webtbf/tw36584.pp Normal file
View File

@ -0,0 +1,23 @@
{ %fail }
{$mode delphi}
program test;
type
TFooA = class
end;
type
TFooB = class
end;
type
TList<T: TFooA> = class
procedure Foo;
end;
procedure TList<T: TFooB>.Foo;
begin
end;
begin
end.