From 8336360cbf371c70e3f9f7fd0b73dc278ffebe6d Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 8 Apr 2023 10:28:55 +0200 Subject: trans-chap2: defer body elaboration if non-immediate body Fix #2402 --- src/vhdl/translate/trans-chap2.adb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 896c7b4e8..e2a2cc398 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -1687,8 +1687,6 @@ package body Trans.Chap2 is declare Spec_Parent : constant Iir := Get_Parent (Spec); Bod : constant Iir := Get_Package_Body (Spec); - Inst_Bod : constant Iir := Get_Instance_Package_Body (Inst); - Final : Boolean; begin -- There are no routines generated to elaborate macro-expanded -- packages, but dependencies still need to be elaborated. @@ -1701,12 +1699,17 @@ package body Trans.Chap2 is Elab_Package (Inst, Inst); - if Inst_Bod /= Null_Iir then + if Get_Immediate_Body_Flag (Inst) then -- Humm, if BOD is present then INST_BOD should also be -- present. But this is true only if the spec needs a body. - Open_Temp; - Chap4.Elab_Declaration_Chain (Inst_Bod, Final); - Close_Temp; + declare + Inst_Bod : constant Iir := Get_Instance_Package_Body (Inst); + Final : Boolean; + begin + Open_Temp; + Chap4.Elab_Declaration_Chain (Inst_Bod, Final); + Close_Temp; + end; end if; end; return; -- cgit v1.2.3