diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-02-19 11:54:49 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-02-19 12:30:40 +0100 |
commit | 3ce8435531d9fe480a5eb47db923eaf9fa4c3273 (patch) | |
tree | db0661325572532a63526a8404e7c073c6641278 | |
parent | f041824100c87e65ae8aaa92dff01988b6fbc94f (diff) | |
download | ghdl-3ce8435531d9fe480a5eb47db923eaf9fa4c3273.tar.gz ghdl-3ce8435531d9fe480a5eb47db923eaf9fa4c3273.tar.bz2 ghdl-3ce8435531d9fe480a5eb47db923eaf9fa4c3273.zip |
trans-chap2: elaborate dependencies of macro-expanded packages.
Fix #2353
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index c4bcc757f..ca8fb6341 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -941,6 +941,10 @@ package body Trans.Chap2 is Chap4.Translate_Declaration_Chain (Bod); Pop_Package_Instance_Factory (Spec); + else + Restore_Local_Identifier (Info.Package_Local_Id); + + Chap4.Translate_Declaration_Chain (Bod); end if; -- May be called during elaboration to generate RTI. @@ -951,12 +955,6 @@ package body Trans.Chap2 is return; end if; - if not (Is_Spec_Decl and then Is_Uninstantiated_Package (Spec)) then - Restore_Local_Identifier (Info.Package_Local_Id); - - Chap4.Translate_Declaration_Chain (Bod); - end if; - Global_Storage := O_Storage_Private; -- Generate RTI, but not for nested packages (RTI will be generated as @@ -1613,22 +1611,21 @@ package body Trans.Chap2 is Translate_Package (Inst, Inst); -- Generate code for the body. - if Global_Storage /= O_Storage_External then - declare - Bod : constant Iir := Get_Instance_Package_Body (Inst); - begin - if Is_Valid (Bod) then - Translate_Package_Body (Bod); - else - -- As an elaboration subprogram for the body is always - -- needed, generate it. + declare + Bod : constant Iir := Get_Instance_Package_Body (Inst); + begin + if Is_Valid (Bod) then + Translate_Package_Body (Bod); + else + -- As an elaboration subprogram for the body is always + -- needed, generate it. + if Global_Storage /= O_Storage_External then if not Is_Nested_Package (Inst) then Elab_Package_Body (Inst, Null_Iir); end if; end if; - end; - end if; - + end if; + end; return; end if; @@ -1688,7 +1685,29 @@ package body Trans.Chap2 is begin -- Macro-expanded instances are handled like a regular package. if Get_Macro_Expanded_Flag (Spec) then - Elab_Package (Inst, Inst); + declare + Bod : constant Iir := Get_Package_Body (Spec); + Inst_Bod : constant Iir := Get_Instance_Package_Body (Inst); + Final : Boolean; + pragma Unreferenced (Final); + begin + -- There are no routines generated to elaborate macro-expanded + -- packages, but dependencies still need to be elaborated. + Elab_Dependence (Get_Design_Unit (Spec)); + if Bod /= Null_Iir then + Elab_Dependence (Get_Design_Unit (Bod)); + end if; + + Elab_Package (Inst, Inst); + + if Inst_Bod /= Null_Iir 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; + end if; + end; return; end if; |