diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-12-10 06:12:33 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-12-11 07:25:09 +0100 |
commit | b9f0289559e16f788262fb33a29a66253d5bc3ec (patch) | |
tree | d32df61b76f0c6f3e37491a24ded64e1cf663231 /src/vhdl | |
parent | e818c1cbbb71c4f406be66e3bd63122fdf69dc98 (diff) | |
download | ghdl-b9f0289559e16f788262fb33a29a66253d5bc3ec.tar.gz ghdl-b9f0289559e16f788262fb33a29a66253d5bc3ec.tar.bz2 ghdl-b9f0289559e16f788262fb33a29a66253d5bc3ec.zip |
Rework subprograms translation for package instance.
Fix #202
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 18 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 6ed07c180..9dd992be3 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -889,12 +889,9 @@ package body Trans.Chap2 is Translate_Package (Decl, Get_Package_Header (Decl)); if Global_Storage = O_Storage_Public then - -- If there are package instances declared that were macro-expanded - -- and if the package has (possibly) no body, translate the bodies - -- of the instances. - if Get_Need_Instance_Bodies (Decl) --- and not Get_Need_Body (Decl) - then + -- If there are package instances declared that were macro-expanded, + -- translate the bodies of the instances. + if Get_Need_Instance_Bodies (Decl) then El := Get_Declaration_Chain (Decl); while Is_Valid (El) loop if Get_Kind (El) = Iir_Kind_Package_Instantiation_Declaration @@ -975,7 +972,7 @@ package body Trans.Chap2 is Info.Package_Body_Scope'Access); end if; - if not Is_Nested or else not Is_Spec_Decl then + if not Is_Nested then -- Translate subprograms. For nested package, this has to be called -- when translating subprograms. Chap4.Translate_Declaration_Chain_Subprograms (Bod); @@ -1390,10 +1387,9 @@ package body Trans.Chap2 is -- Macro-expanded instantiations are translated like a package. Translate_Package (Inst, Inst); - -- For top-level package, generate code for the body. - if Global_Storage = O_Storage_Public - and then not Is_Nested_Package (Inst) - then + -- For top-level package or nested package not within a package, + -- generate code for the body. + if Global_Storage = O_Storage_Public then declare Bod : constant Iir := Get_Package_Body (Inst); begin diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index ba5853935..8c44f7c49 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -2393,10 +2393,14 @@ package body Trans.Chap4 is (Get_Uninstantiated_Package_Decl (El)) then declare + Bod : constant Iir := Get_Package_Body (El); Mark : Id_Mark_Type; begin Push_Identifier_Prefix (Mark, Get_Identifier (El)); Translate_Declaration_Chain_Subprograms (El); + if Is_Valid (Bod) then + Translate_Declaration_Chain_Subprograms (Bod); + end if; Pop_Identifier_Prefix (Mark); end; end if; |