mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-22 22:11:34 +02:00
* forbid anonymous generic specializations
git-svn-id: trunk@6627 -
This commit is contained in:
parent
6aad495cbb
commit
301be02148
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7176,6 +7176,7 @@ tests/webtbf/tw7322.pp svneol=native#text/plain
|
||||
tests/webtbf/tw7438.pp svneol=native#text/plain
|
||||
tests/webtbf/tw7438a.pp svneol=native#text/plain
|
||||
tests/webtbf/tw7989.pp svneol=native#text/plain
|
||||
tests/webtbf/tw7998.pp svneol=native#text/plain
|
||||
tests/webtbf/tw8019.pp svneol=native#text/plain
|
||||
tests/webtbf/tw8031.pp svneol=native#text/plain
|
||||
tests/webtbf/tw8140a.pp svneol=native#text/plain
|
||||
|
@ -398,7 +398,7 @@ parser_n_only_one_destructor=03020_N_Class should have one destructor only
|
||||
parser_e_no_local_objects=03021_E_Local class definitions are not allowed
|
||||
% Classes must be defined globally. They cannot be defined inside a
|
||||
% procedure or function
|
||||
parser_f_no_anonym_objects=03022_F_Anonym class definitions are not allowed
|
||||
parser_f_no_anonym_objects=03022_F_Anonymous class definitions are not allowed
|
||||
% An invalid object (class) declaration was encountered, i.e. an
|
||||
% object or class without methods that isn't derived from another object or
|
||||
% class. For example:
|
||||
@ -1115,6 +1115,19 @@ parser_e_type_object_constants=03230_E_Constants of objects containing a VMT are
|
||||
parser_e_label_outside_proc=03231_E_Taking the address of labels defined outside the current scope isn't allowed
|
||||
% It isn't allowed to take the addresss of labels outside the
|
||||
% current procedure.
|
||||
parser_f_no_anonymous_specializations=03232_F_Anonymous generic specializations are not allowed
|
||||
% Something like
|
||||
% \begin{verbatim}
|
||||
% var
|
||||
% MyLinkedList: specialize TLinkedList<TFixedString15>;
|
||||
% \end{verbatim}
|
||||
% is not allowed. Declare a specialized type first:
|
||||
% \begin{verbatim}
|
||||
% type
|
||||
% TMyLinkedList = specialize TLinkedList<TFixedString15>;
|
||||
% var
|
||||
% MyLinkedList: TMyLinkedList
|
||||
% \end{verbatim}
|
||||
% \end{description}
|
||||
#
|
||||
# Type Checking
|
||||
|
@ -316,6 +316,7 @@ const
|
||||
parser_e_no_generics_as_params=03229;
|
||||
parser_e_type_object_constants=03230;
|
||||
parser_e_label_outside_proc=03231;
|
||||
parser_f_no_anonymous_specializations=03232;
|
||||
type_e_mismatch=04000;
|
||||
type_e_incompatible_types=04001;
|
||||
type_e_not_equal_types=04002;
|
||||
@ -718,9 +719,9 @@ const
|
||||
option_info=11024;
|
||||
option_help_pages=11025;
|
||||
|
||||
MsgTxtSize = 42777;
|
||||
MsgTxtSize = 42881;
|
||||
|
||||
MsgIdxMax : array[1..20] of longint=(
|
||||
24,82,232,79,63,48,107,22,135,60,
|
||||
24,82,233,79,63,48,107,22,135,60,
|
||||
42,1,1,1,1,1,1,1,1,1
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -265,6 +265,8 @@ implementation
|
||||
begin
|
||||
if try_to_consume(_SPECIALIZE) then
|
||||
begin
|
||||
if block_type<>bt_type then
|
||||
Message(parser_f_no_anonymous_specializations);
|
||||
block_type:=bt_specialize;
|
||||
again:=true;
|
||||
end
|
||||
@ -351,7 +353,11 @@ implementation
|
||||
end;
|
||||
{ Generate a specialization? }
|
||||
if try_to_consume(_SPECIALIZE) then
|
||||
block_type:=bt_specialize;
|
||||
begin
|
||||
if name='' then
|
||||
Message(parser_f_no_anonymous_specializations);
|
||||
block_type:=bt_specialize;
|
||||
end;
|
||||
{ we can't accept a equal in type }
|
||||
pt1:=comp_expr(false);
|
||||
if (block_type<>bt_specialize) and
|
||||
|
24
tests/webtbf/tw7998.pp
Normal file
24
tests/webtbf/tw7998.pp
Normal file
@ -0,0 +1,24 @@
|
||||
{ %fail }
|
||||
program testarray3;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
type
|
||||
TFixedString15 = array[1..15] of char;
|
||||
generic TLinkedList<T> = class
|
||||
type
|
||||
PNode = ^TNode;
|
||||
TNode = record
|
||||
key: T;
|
||||
value : dword;
|
||||
next : PNode;
|
||||
end;
|
||||
var
|
||||
first: PNode;
|
||||
end;
|
||||
|
||||
var
|
||||
MyLinkedList: specialize TLinkedList<TFixedString15>;
|
||||
|
||||
begin
|
||||
end.
|
Loading…
Reference in New Issue
Block a user