From 4245b20a32206201500e7d9c646b003b93f4c6e9 Mon Sep 17 00:00:00 2001
From: yury <jura@cp-lab.com>
Date: Thu, 11 Feb 2021 10:39:41 +0000
Subject: [PATCH] * Fixed expectloc of local variables passed as a formal
 parameter. This issue is caught by cycling the compiler with -dEXTDEBUG. Yet
 the compiler can't cycle with EXTDEBUG due to other issues with wrong
 expectloc.

git-svn-id: trunk@48650 -
---
 compiler/ncal.pas | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/compiler/ncal.pas b/compiler/ncal.pas
index 4bf6208858..25e2aa209c 100644
--- a/compiler/ncal.pas
+++ b/compiler/ncal.pas
@@ -1392,6 +1392,16 @@ implementation
                         else
                           make_not_regable(left,[ra_addr_regable])
                       end;
+                    vs_const:
+                      if parasym.vardef.typ=formaldef then
+                        begin
+                          { compilerprocs never capture the address of their
+                            parameters }
+                          if not(po_compilerproc in aktcallnode.procdefinition.procoptions) then
+                            make_not_regable(left,[ra_addr_regable,ra_addr_taken])
+                          else
+                            make_not_regable(left,[ra_addr_regable])
+                        end;
                     else
                       set_varstate(left,vs_read,[vsf_must_be_valid]);
                   end;