diff --git a/compiler/psub.pas b/compiler/psub.pas index 9fd7ba2685..a11555717f 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -608,7 +608,7 @@ implementation oldprocinfo : tprocinfo; oldaktmaxfpuregisters : longint; oldfilepos : tfileposinfo; - templist : Taasmoutput; + templist, symlist : Taasmoutput; headertai : tai; curralign : longint; begin @@ -637,6 +637,7 @@ implementation aktbreaklabel:=nil; aktcontinuelabel:=nil; templist:=Taasmoutput.create; + symlist:=Taasmoutput.create; { add parast/localst to symtablestack } add_to_symtablestack; @@ -682,6 +683,12 @@ implementation set_first_temp_offset; generate_parameter_info; + { allocate the symbol associated with the procedure, so that } + { references to itself are not treated as references to } + { externals } + aktfilepos:=entrypos; + gen_proc_symbol(symlist); + { Allocate space in temp/registers for parast and localst } aktfilepos:=entrypos; gen_alloc_symtable(aktproccode,procdef.parast); @@ -771,10 +778,9 @@ implementation { generate symbol and save end of header position } aktfilepos:=entrypos; - gen_proc_symbol(templist); - headertai:=tai(templist.last); + headertai:=tai(symlist.last); { insert symbol } - aktproccode.insertlist(templist); + aktproccode.insertlist(symlist); { Free space in temp/registers for parast and localst, must be done after gen_entry_code }