소스 검색

* give a better error message and do better error recovery if too few typed constant array elements are provided

git-svn-id: trunk@14708 -
florian 15 년 전
부모
커밋
cf5c42b596
6개의 변경된 파일299개의 추가작업 그리고 282개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 4 2
      compiler/msg/errore.msg
  3. 3 2
      compiler/msgidx.inc
  4. 277 277
      compiler/msgtxt.inc
  5. 8 1
      compiler/ptconst.pas
  6. 6 0
      tests/test/ttypedarray1.pp

+ 1 - 0
.gitattributes

@@ -9258,6 +9258,7 @@ tests/test/tsubdecl.pp svneol=native#text/plain
 tests/test/tsymlibrary1.pp svneol=native#text/pascal
 tests/test/ttpara1.pp svneol=native#text/plain
 tests/test/ttpara2.pp svneol=native#text/plain
+tests/test/ttypedarray1.pp svneol=native#text/pascal
 tests/test/tunaligned1.pp svneol=native#text/plain
 tests/test/tunistr1.pp svneol=native#text/plain
 tests/test/tunistr2.pp svneol=native#text/plain

+ 4 - 2
compiler/msg/errore.msg

@@ -1281,11 +1281,13 @@ parser_e_no_refcounted_typed_file=03282_E_Typed files cannot contain reference-c
 % The data in a typed file cannot be of a reference counted type (such as
 % \var{ansistring} or a record containing a field that is reference counted).
 parser_e_operator_not_overloaded_2=03283_E_Operator is not overloaded: $2 "$1"
-% You're trying to use an overloaded operator when it is not overloaded for
+% You are trying to use an overloaded operator when it is not overloaded for
 % this type.
 parser_e_operator_not_overloaded_3=03284_E_Operator is not overloaded: "$1" $2 "$3"
-% You're trying to use an overloaded operator when it is not overloaded for
+% You are trying to use an overloaded operator when it is not overloaded for
 % this type.
+parser_e_more_array_elements_expected=03285_E_Expected another $1 array elements
+% When declaring a typed constant array, you provided to few elements to initialize the array
 % \end{description}
 #
 # Type Checking

+ 3 - 2
compiler/msgidx.inc

@@ -372,6 +372,7 @@ const
   parser_e_no_refcounted_typed_file=03282;
   parser_e_operator_not_overloaded_2=03283;
   parser_e_operator_not_overloaded_3=03284;
+  parser_e_more_array_elements_expected=03285;
   type_e_mismatch=04000;
   type_e_incompatible_types=04001;
   type_e_not_equal_types=04002;
@@ -843,9 +844,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 55433;
+  MsgTxtSize = 55476;
 
   MsgIdxMax : array[1..20] of longint=(
-    24,87,285,95,74,51,110,22,202,63,
+    24,87,286,95,74,51,110,22,202,63,
     49,20,1,1,1,1,1,1,1,1
   );

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 277 - 277
compiler/msgtxt.inc


+ 8 - 1
compiler/ptconst.pas

@@ -847,7 +847,14 @@ implementation
                 begin
                   read_typed_const_data(hr,def.elementdef);
                   Inc(hr.offset,def.elementdef.size);
-                  consume(_COMMA);
+                  if token=_RKLAMMER then
+                    begin
+                      Message1(parser_e_more_array_elements_expected,tostr(def.highrange-i));
+                      consume(_RKLAMMER);
+                      exit;
+                    end
+                  else
+                    consume(_COMMA);
                 end;
               read_typed_const_data(hr,def.elementdef);
               consume(_RKLAMMER);

+ 6 - 0
tests/test/ttypedarray1.pp

@@ -0,0 +1,6 @@
+{ %fail }
+const
+  a : array[0..10] of longint = (1,2);
+
+begin
+end.

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.