diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index d68ca73a5f..feed3f5028 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -1970,7 +1970,8 @@ type resources_used : boolean; program_uses_checkpointer : boolean; program_name : ansistring; - consume_semicolon_after_uses : boolean; + consume_semicolon_after_uses, + consume_semicolon_after_loaded : boolean; ps : tprogramparasym; paramnum : longint; textsym : ttypesym; @@ -1987,6 +1988,8 @@ type init_procinfo:=nil; finalize_procinfo:=nil; resources_used:=false; + consume_semicolon_after_loaded:=false; + { make the compiler happy and avoid an uninitialized variable warning on Setlength(sc,length(sc)+1); } sc:=nil; @@ -2049,7 +2052,7 @@ type read, all following directives are parsed as well } setupglobalswitches; - consume(_SEMICOLON); + consume_semicolon_after_loaded:=true; {$ifdef DEBUG_NODE_XML} XMLInitializeNodeFile('library', program_name); @@ -2099,7 +2102,7 @@ type read, all following directives are parsed as well } setupglobalswitches; - consume(_SEMICOLON); + consume_semicolon_after_loaded:=true; {$ifdef DEBUG_NODE_XML} XMLInitializeNodeFile('program', program_name); @@ -2122,9 +2125,6 @@ type package or not } load_packages; - { global switches are read, so further changes aren't allowed } - current_module.in_global:=false; - { set implementation flag } current_module.in_interface:=false; current_module.interface_compiled:=true; @@ -2136,6 +2136,13 @@ type { load system unit } loadsystemunit; + { consume the semicolon now that the system unit is loaded } + if consume_semicolon_after_loaded then + consume(_SEMICOLON); + + { global switches are read, so further changes aren't allowed } + current_module.in_global:=false; + { system unit is loaded, now insert feature defines } for feature:=low(tfeature) to high(tfeature) do if feature in features then