2
0
Эх сурвалжийг харах

* fix for Mantis #31795: append a $ to internal functions init, finalize, init_implicit and finalize_implicit as their section names otherwise look the same as those of user declared functions with the same name
+ added test

git-svn-id: trunk@36194 -

svenbarth 8 жил өмнө
parent
commit
c90fbe1bf0

+ 1 - 0
.gitattributes

@@ -15489,6 +15489,7 @@ tests/webtbs/tw3173.pp svneol=native#text/plain
 tests/webtbs/tw3174.pp svneol=native#text/plain
 tests/webtbs/tw3176.pp svneol=native#text/plain
 tests/webtbs/tw3179.pp svneol=native#text/plain
+tests/webtbs/tw31795.pp svneol=native#text/pascal
 tests/webtbs/tw3182.pp svneol=native#text/plain
 tests/webtbs/tw3183.pp svneol=native#text/plain
 tests/webtbs/tw3183a.pp svneol=native#text/plain

+ 5 - 5
compiler/pmodules.pas

@@ -694,12 +694,12 @@ implementation
         case flag of
           uf_init :
             begin
-              result:=create_main_proc(make_mangledname('',current_module.localsymtable,'init_implicit'),potype_unitinit,st);
+              result:=create_main_proc(make_mangledname('',current_module.localsymtable,'init_implicit$'),potype_unitinit,st);
               result.procdef.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
             end;
           uf_finalize :
             begin
-              result:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize_implicit'),potype_unitfinalize,st);
+              result:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize_implicit$'),potype_unitfinalize,st);
               result.procdef.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
               if (not current_module.is_unit) then
                 result.procdef.aliasnames.insert('PASCALFINALIZE');
@@ -1035,7 +1035,7 @@ type
                internalerror(200212285);
 
              { Compile the unit }
-             init_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'init'),potype_unitinit,current_module.localsymtable);
+             init_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'init$'),potype_unitinit,current_module.localsymtable);
              init_procinfo.procdef.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
              init_procinfo.parse_body;
              { save file pos for debuginfo }
@@ -1045,7 +1045,7 @@ type
              if token=_FINALIZATION then
                begin
                  { Compile the finalize }
-                 finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,current_module.localsymtable);
+                 finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize$'),potype_unitfinalize,current_module.localsymtable);
                  finalize_procinfo.procdef.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
                  finalize_procinfo.parse_body;
                end
@@ -2112,7 +2112,7 @@ type
          if token=_FINALIZATION then
            begin
               { Parse the finalize }
-              finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,current_module.localsymtable);
+              finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize$'),potype_unitfinalize,current_module.localsymtable);
               finalize_procinfo.procdef.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
               finalize_procinfo.procdef.aliasnames.insert('PASCALFINALIZE');
               finalize_procinfo.parse_body;

+ 43 - 0
tests/webtbs/tw31795.pp

@@ -0,0 +1,43 @@
+unit tw31795;
+
+{$mode objfpc}{$H+}
+
+interface
+uses
+  Classes, SysUtils;
+
+type
+  TCriticalSection = class(TObject)
+
+  end;
+
+implementation
+
+var
+  gbbbbb : TCriticalSection;
+
+procedure init;
+var
+  s: String;
+begin
+  s := 'Hello World';
+end;
+
+procedure Finalize;
+var
+  s: String;
+begin
+  s := 'Hello World';
+end;
+
+initialization
+
+  gbbbbb := TCriticalSection.Create;
+
+finalization
+
+  gbbbbb.free;
+
+end.
+
+