Sfoglia il codice sorgente

compiler: don't allow for-in loop for the enums with jumps. test should fail.

git-svn-id: trunk@14067 -
paul 15 anni fa
parent
commit
5c660680b7
5 ha cambiato i file con 303 aggiunte e 288 eliminazioni
  1. 3 1
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 285 284
      compiler/msgtxt.inc
  4. 11 1
      compiler/nflw.pas
  5. 1 0
      tests/test/tforin20.pp

+ 3 - 1
compiler/msg/errore.msg

@@ -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

+ 3 - 2
compiler/msgidx.inc

@@ -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
+ 285 - 284
compiler/msgtxt.inc


+ 11 - 1
compiler/nflw.pas

@@ -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 - 0
tests/test/tforin20.pp

@@ -1,3 +1,4 @@
+{ %FAIL}
 {$mode objfpc}
 {$apptype console}
 type T = (a1, b1=5);

Some files were not shown because too many files changed in this diff