From b95cc40ac667768cd0ae03adb8c9c8c21ad35a30 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 24 Mar 2023 19:28:04 +0100 Subject: vhdl: add Owned_Instance_Package_Body to handle ownership of package body. --- src/vhdl/vhdl-sem_inst.adb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/vhdl/vhdl-sem_inst.adb') diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb index 02e63836d..75d0cc678 100644 --- a/src/vhdl/vhdl-sem_inst.adb +++ b/src/vhdl/vhdl-sem_inst.adb @@ -605,20 +605,32 @@ package body Vhdl.Sem_Inst is -- case set the forward link. -- Or it can be the body of an instantiated package; in -- that case there is no forward link. - if Get_Kind (Pkg) = Iir_Kind_Package_Declaration then - Set_Package_Body (Get_Package (Res), Res); - end if; + case Get_Kind (Pkg) is + when Iir_Kind_Package_Declaration => + Set_Package_Body (Pkg, Res); + when Iir_Kind_Package_Instantiation_Declaration => + Set_Instance_Package_Body (Pkg, Res); + when others => + raise Internal_Error; + end case; end; - when Field_Instance_Package_Body => + when Field_Owned_Instance_Package_Body => -- Do not instantiate the body of a package while -- instantiating a shared package. if not Is_Within_Shared_Instance then - Set_Instance_Package_Body - (Res, Instantiate_Iir (Get_Instance_Package_Body (N), - False)); + declare + Bod : Iir; + begin + Bod := Instantiate_Iir (Get_Instance_Package_Body (N), + False); + Set_Owned_Instance_Package_Body (Res, Bod); + end; end if; + when Field_Instance_Package_Body => + null; + when Field_Subtype_Definition => -- TODO null; -- cgit v1.2.3