فهرست منبع

* Forbid use of string alias in system unit

Michael VAN CANNEYT 2 سال پیش
والد
کامیت
391fdcac08
6فایلهای تغییر یافته به همراه415 افزوده شده و 397 حذف شده
  1. 3 0
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 400 394
      compiler/msgtxt.inc
  4. 2 0
      compiler/pbase.pas
  5. 5 0
      compiler/pexpr.pas
  6. 2 1
      compiler/ptype.pas

+ 3 - 0
compiler/msg/errore.msg

@@ -1647,6 +1647,9 @@ parser_w_ignoring_published_property=03365_W_This property will not be published
 parser_w_widechar_set_reduced=03366_W_Reducing Widechar set to single-byte AnsiChar set.
 % The base type of a set can only have 255 elements. Sets of wide characters
 % are reduced to sets of 1-byte characters.
+parser_e_nostringaliasinsystem=03367_e_Using 'string' alias is not allowed in the system unit. Use short-,ansi- or unicodestring.
+% As a safeguard, the system unit may only use basic string types, not the
+% string alias which is dependent on the mode in which a unit is compiled.
 %
 % \end{description}
 %

+ 3 - 2
compiler/msgidx.inc

@@ -480,6 +480,7 @@ const
   parser_e_syscall_format_not_support=03364;
   parser_w_ignoring_published_property=03365;
   parser_w_widechar_set_reduced=03366;
+  parser_e_nostringaliasinsystem=03367;
   type_e_mismatch=04000;
   type_e_incompatible_types=04001;
   type_e_not_equal_types=04002;
@@ -1161,9 +1162,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 90971;
+  MsgTxtSize = 91070;
 
   MsgIdxMax : array[1..20] of longint=(
-    28,109,367,132,100,63,148,38,223,71,
+    28,109,368,132,100,63,148,38,223,71,
     68,20,30,1,1,1,1,1,1,1
   );

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 400 - 394
compiler/msgtxt.inc


+ 2 - 0
compiler/pbase.pas

@@ -399,6 +399,8 @@ implementation
                      end;
                   _STRING:
                     begin
+                      if cs_compilesystem in current_settings.moduleswitches then
+                        Message(parser_e_nostringaliasinsystem);
                       { system.string? }
                       if tmodule(tunitsym(srsym).module).globalsymtable=systemunit then
                         begin

+ 5 - 0
compiler/pexpr.pas

@@ -141,6 +141,9 @@ implementation
            end
           else
             begin
+             // string[x] is allowed in system unit since it is a shortstring.
+             if cs_compilesystem in current_settings.moduleswitches then
+               Message(parser_e_nostringaliasinsystem);
               if cs_refcountedstrings in current_settings.localswitches then
                 begin
                   if m_default_unicodestring in current_settings.modeswitches then
@@ -4032,6 +4035,8 @@ implementation
 
              _STRING :
                begin
+                 if cs_compilesystem in current_settings.moduleswitches then
+                   Message(parser_e_nostringaliasinsystem);
                  string_dec(hdef,true);
                  { STRING can be also a type cast }
                  if try_to_consume(_LKLAMMER) then

+ 2 - 1
compiler/ptype.pas

@@ -494,8 +494,9 @@ implementation
            again:=false;
              case token of
                _STRING:
+                 begin
                  string_dec(def,stoAllowTypeDef in options);
-
+                 end;
                _FILE:
                  begin
                     consume(_FILE);

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است