فهرست منبع

LLVM: always added related high parameters to parentfpstruct

Sometimes the high parameter is only first accessed during the first
pass, while we already need to know everything that will go into the
parentfpstruct during the typechecking pass.

resolves #41282
Jonas Maebe 1 ماه پیش
والد
کامیت
5f215e8126
2فایلهای تغییر یافته به همراه31 افزوده شده و 0 حذف شده
  1. 8 0
      compiler/symcreat.pas
  2. 23 0
      tests/webtbs/tw41282.pp

+ 8 - 0
compiler/symcreat.pas

@@ -1990,6 +1990,7 @@ implementation
       old_filepos: tfileposinfo;
       old_filepos: tfileposinfo;
       symname,
       symname,
       symrealname: TSymStr;
       symrealname: TSymStr;
+      highsym: tabstractvarsym;
     begin
     begin
       nestedvarsdef:=tlocalvarsym(pd.parentfpstruct).vardef;
       nestedvarsdef:=tlocalvarsym(pd.parentfpstruct).vardef;
       { redirect all aliases for the function result also to the function
       { redirect all aliases for the function result also to the function
@@ -2044,6 +2045,13 @@ implementation
               tblocknode(pd.parentfpinitblock).left:=cstatementnode.create
               tblocknode(pd.parentfpinitblock).left:=cstatementnode.create
                 (initcode,tblocknode(pd.parentfpinitblock).left);
                 (initcode,tblocknode(pd.parentfpinitblock).left);
               current_filepos:=old_filepos;
               current_filepos:=old_filepos;
+
+              { also add the associated high para, if any. It may not be accessed
+                during code generation, and we need to catch 'em all (TM) during
+                the typecheck/firstpass }
+              highsym:=get_high_value_sym(tparavarsym(sym));
+              if assigned(highsym) then
+                maybe_add_sym_to_parentfpstruct(pd, highsym, highsym.vardef, false);
             end;
             end;
         end;
         end;
     end;
     end;

+ 23 - 0
tests/webtbs/tw41282.pp

@@ -0,0 +1,23 @@
+{$mode delphi}
+
+Program test;
+
+procedure outer_proc(var outer: ShortString);
+
+procedure inner_proc;
+Begin
+  outer := 'abc';
+End;
+
+Begin
+  inner_proc();
+End;
+
+var
+ s: shortstring;
+
+Begin
+  outer_proc(s);
+  if s<>'abc' then
+    halt(1);
+End.