Browse Source

* Check that system unit is actually loaded before using it to search for system symbols

(cherry picked from commit 9e5ee68887dcb8acf66caf873bc5cfc58fb25316)
Michael VAN CANNEYT 2 years ago
parent
commit
a74a35a16e
4 changed files with 348 additions and 330 deletions
  1. 5 0
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 331 328
      compiler/msgtxt.inc
  4. 9 0
      compiler/symtable.pas

+ 5 - 0
compiler/msg/errore.msg

@@ -30,6 +30,7 @@
 #   exec_     calls to assembler, external linker, binder
 #   link_     internal linker
 #   package_  package handling
+#   sym_      symbol handling 
 #
 # <type> the type of the message it should normally used for
 #   f_   fatal error
@@ -2431,6 +2432,10 @@ sym_e_type_must_be_rec_or_object=05098_E_Record or object type expected
 sym_e_symbol_no_capture=05099_E_Symbol "$1" can not be captured
 % The specified symbol can not be captured to be used in a function reference.
 % For example \var{var} or \var{out} parameters can not be captured in that way.
+sym_f_systemunitnotloaded=05100_F_System unit not loaded.
+% The compiler used a function that requires the system unit to be loaded,
+% but it was not yet loaded. This is an internal compiler error and must be reported.
+%
 % \end{description}
 #
 # Codegenerator

+ 3 - 2
compiler/msgidx.inc

@@ -687,6 +687,7 @@ const
   sym_e_generic_type_param_decl=05097;
   sym_e_type_must_be_rec_or_object=05098;
   sym_e_symbol_no_capture=05099;
+  sym_f_systemunitnotloaded=05100;
   cg_e_parasize_too_big=06009;
   cg_e_file_must_call_by_reference=06012;
   cg_e_cant_use_far_pointer_there=06013;
@@ -1160,9 +1161,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 91007;
+  MsgTxtSize = 91039;
 
   MsgIdxMax : array[1..20] of longint=(
-    28,109,366,132,100,63,148,38,223,71,
+    28,109,366,132,101,63,148,38,223,71,
     68,20,30,1,1,1,1,1,1,1
   );

File diff suppressed because it is too large
+ 331 - 328
compiler/msgtxt.inc


+ 9 - 0
compiler/symtable.pas

@@ -3071,11 +3071,17 @@ implementation
           end;
       end;
 
+    procedure check_systemunit_loaded; inline;
+    begin
+      if systemunit=nil then
+       Message(sym_f_systemunitnotloaded);
+    end;
 
     procedure write_system_parameter_lists(const name:string);
       var
         srsym:tprocsym;
       begin
+        check_systemunit_loaded;
         srsym:=tprocsym(systemunit.find(name));
         if not assigned(srsym) or not (srsym.typ=procsym) then
           internalerror(2016060302);
@@ -4219,6 +4225,7 @@ implementation
       var
         sym : tsym;
       begin
+        check_systemunit_loaded;
         sym:=tsym(systemunit.Find(s));
         if not assigned(sym) or
            (sym.typ<>typesym) then
@@ -4231,6 +4238,7 @@ implementation
       var
         sym : tsym;
       begin
+        check_systemunit_loaded;
         sym:=tsym(systemunit.Find(s));
         if not assigned(sym) then
           result:=nil
@@ -4268,6 +4276,7 @@ implementation
       var
         srsym: tsym;
       begin
+        check_systemunit_loaded;
         srsym:=tsym(systemunit.find(s));
         if not assigned(srsym) and
            (cs_compilesystem in current_settings.moduleswitches) then

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