mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 07:08:12 +02:00
compiler: don't allow for-in loop for the enums with jumps. test should fail.
git-svn-id: trunk@14067 -
This commit is contained in:
parent
7db712c566
commit
5c660680b7
@ -366,7 +366,7 @@ scan_w_multiple_main_name_overrides=02086_W_Overriding name of "main" procedure
|
||||
#
|
||||
# Parser
|
||||
#
|
||||
# 03264 is the last used one
|
||||
# 03265 is the last used one
|
||||
#
|
||||
% \section{Parser messages}
|
||||
% This section lists all parser messages. The parser takes care of the
|
||||
@ -1215,6 +1215,8 @@ parser_e_only_one_enumerator_movenext=03263_E_Only one enumerator MoveNext metho
|
||||
% Class or Object can have only one enumerator MoveNext declaration.
|
||||
parser_e_only_one_enumerator_current=03264_E_Only one enumerator Current property is allowed per class/object
|
||||
% Class or Object can have only one enumerator Current declaration.
|
||||
parser_e_for_in_loop_cannot_be_used_for_the_type=03265_E_For in loop can not be used for the type "$1"
|
||||
% For in loop can be used not for all types. For example it can not be used for the enumerations with jumps.
|
||||
% \end{description}
|
||||
#
|
||||
# Type Checking
|
||||
|
@ -352,6 +352,7 @@ const
|
||||
parser_e_enumerator_current_is_not_valid=03262;
|
||||
parser_e_only_one_enumerator_movenext=03263;
|
||||
parser_e_only_one_enumerator_current=03264;
|
||||
parser_e_for_in_loop_cannot_be_used_for_the_type=03265;
|
||||
type_e_mismatch=04000;
|
||||
type_e_incompatible_types=04001;
|
||||
type_e_not_equal_types=04002;
|
||||
@ -810,9 +811,9 @@ const
|
||||
option_info=11024;
|
||||
option_help_pages=11025;
|
||||
|
||||
MsgTxtSize = 52763;
|
||||
MsgTxtSize = 52817;
|
||||
|
||||
MsgIdxMax : array[1..20] of longint=(
|
||||
24,87,265,91,70,50,108,22,202,62,
|
||||
24,87,266,91,70,50,108,22,202,62,
|
||||
48,20,1,1,1,1,1,1,1,1
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -568,7 +568,17 @@ var
|
||||
current: tpropertysym;
|
||||
begin
|
||||
if expr.nodetype=typen then
|
||||
result:=create_type_for_in_loop(hloopvar, hloopbody, expr)
|
||||
begin
|
||||
if (expr.resultdef.typ=enumdef) and tenumdef(expr.resultdef).has_jumps then
|
||||
begin
|
||||
result:=cerrornode.create;
|
||||
hloopvar.free;
|
||||
hloopbody.free;
|
||||
Message1(parser_e_for_in_loop_cannot_be_used_for_the_type,expr.resultdef.typename);
|
||||
end
|
||||
else
|
||||
result:=create_type_for_in_loop(hloopvar, hloopbody, expr);
|
||||
end
|
||||
else
|
||||
begin
|
||||
{ loop is made for an expression }
|
||||
|
@ -1,3 +1,4 @@
|
||||
{ %FAIL}
|
||||
{$mode objfpc}
|
||||
{$apptype console}
|
||||
type T = (a1, b1=5);
|
||||
|
Loading…
Reference in New Issue
Block a user