浏览代码

* delay parsing of the closing SEMICOLON of a uses clause till the
unit map is updated to avoid symbols not being found, resolves #8611

git-svn-id: trunk@23886 -

florian 12 年之前
父节点
当前提交
784641ec46
共有 3 个文件被更改,包括 39 次插入5 次删除
  1. 1 0
      .gitattributes
  2. 26 5
      compiler/pmodules.pas
  3. 12 0
      tests/webtbs/tw8611.pp

+ 1 - 0
.gitattributes

@@ -13897,6 +13897,7 @@ tests/webtbs/tw8523.pp svneol=native#text/plain
 tests/webtbs/tw8525.pp svneol=native#text/plain
 tests/webtbs/tw8525.pp svneol=native#text/plain
 tests/webtbs/tw8573.pp svneol=native#text/plain
 tests/webtbs/tw8573.pp svneol=native#text/plain
 tests/webtbs/tw8580.pp svneol=native#text/plain
 tests/webtbs/tw8580.pp svneol=native#text/plain
+tests/webtbs/tw8611.pp svneol=native#text/pascal
 tests/webtbs/tw8615.pp svneol=native#text/plain
 tests/webtbs/tw8615.pp svneol=native#text/plain
 tests/webtbs/tw8633.pp svneol=native#text/plain
 tests/webtbs/tw8633.pp svneol=native#text/plain
 tests/webtbs/tw8660.pp svneol=native#text/plain
 tests/webtbs/tw8660.pp svneol=native#text/plain

+ 26 - 5
compiler/pmodules.pas

@@ -502,8 +502,6 @@ implementation
              end;
              end;
             pu:=tused_unit(pu.next);
             pu:=tused_unit(pu.next);
           end;
           end;
-
-         consume(_SEMICOLON);
       end;
       end;
 
 
 
 
@@ -542,7 +540,10 @@ implementation
     procedure parse_implementation_uses;
     procedure parse_implementation_uses;
       begin
       begin
          if token=_USES then
          if token=_USES then
-           loadunits;
+           begin
+             loadunits;
+             consume(_SEMICOLON);
+           end;
       end;
       end;
 
 
 
 
@@ -743,6 +744,7 @@ type
          i,j : longint;
          i,j : longint;
          finishstate:pfinishstate;
          finishstate:pfinishstate;
          globalstate:pglobalstate;
          globalstate:pglobalstate;
+         consume_semicolon_after_uses:boolean;
       begin
       begin
          result:=true;
          result:=true;
 
 
@@ -847,7 +849,10 @@ type
              { has it been compiled at a higher level ?}
              { has it been compiled at a higher level ?}
              if current_module.state=ms_compiled then
              if current_module.state=ms_compiled then
                exit;
                exit;
-           end;
+             consume_semicolon_after_uses:=true;
+           end
+         else
+           consume_semicolon_after_uses:=false;
 
 
          { move the global symtable from the temporary local to global }
          { move the global symtable from the temporary local to global }
          current_module.globalsymtable:=current_module.localsymtable;
          current_module.globalsymtable:=current_module.localsymtable;
@@ -857,6 +862,11 @@ type
            needs to be added implicitly }
            needs to be added implicitly }
          current_module.updatemaps;
          current_module.updatemaps;
 
 
+         { consume the semicolon after maps have been updated else conditional compiling expressions
+           might cause internal errors, see tw8611 }
+         if consume_semicolon_after_uses then
+           consume(_SEMICOLON);
+
          { create whole program optimisation information (may already be
          { create whole program optimisation information (may already be
            updated in the interface, e.g., in case of classrefdef typed
            updated in the interface, e.g., in case of classrefdef typed
            constants }
            constants }
@@ -1889,6 +1899,7 @@ type
          force_init_final : boolean;
          force_init_final : boolean;
          resources_used : boolean;
          resources_used : boolean;
          program_name : ansistring;
          program_name : ansistring;
+         consume_semicolon_after_uses : boolean;
       begin
       begin
          DLLsource:=islibrary;
          DLLsource:=islibrary;
          Status.IsLibrary:=IsLibrary;
          Status.IsLibrary:=IsLibrary;
@@ -2004,11 +2015,21 @@ type
 
 
          {Load the units used by the program we compile.}
          {Load the units used by the program we compile.}
          if token=_USES then
          if token=_USES then
-           loadunits;
+           begin
+             loadunits;
+             consume_semicolon_after_uses:=true;
+           end
+         else
+           consume_semicolon_after_uses:=false;
 
 
          { All units are read, now give them a number }
          { All units are read, now give them a number }
          current_module.updatemaps;
          current_module.updatemaps;
 
 
+         { consume the semicolon after maps have been updated else conditional compiling expressions
+           might cause internal errors, see tw8611 }
+         if consume_semicolon_after_uses then
+           consume(_SEMICOLON);
+
          {Insert the name of the main program into the symbol table.}
          {Insert the name of the main program into the symbol table.}
          if current_module.realmodulename^<>'' then
          if current_module.realmodulename^<>'' then
            tabstractunitsymtable(current_module.localsymtable).insertunit(tunitsym.create(current_module.realmodulename^,current_module));
            tabstractunitsymtable(current_module.localsymtable).insertunit(tunitsym.create(current_module.realmodulename^,current_module));

+ 12 - 0
tests/webtbs/tw8611.pp

@@ -0,0 +1,12 @@
+program ie200501152;
+
+{$mode objfpc}
+
+uses
+  Classes;
+
+  {$if declared(TObject)}
+  {$endif}
+
+begin
+end.