aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/canon.adb29
-rw-r--r--src/vhdl/translate/trans-chap12.adb4
-rw-r--r--src/vhdl/translate/translation.adb6
3 files changed, 23 insertions, 16 deletions
diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb
index a23bbeb3f..471058843 100644
--- a/src/vhdl/canon.adb
+++ b/src/vhdl/canon.adb
@@ -2613,7 +2613,7 @@ package body Canon is
Location_Copy (New_Decl, Decl);
Set_Parent (New_Decl, Get_Parent (Decl));
Set_Identifier (New_Decl, Get_Identifier (Decl));
- Set_Need_Body (New_Decl, Get_Need_Body (Pkg));
+ Set_Need_Body (New_Decl, False);
New_Hdr := Create_Iir (Iir_Kind_Package_Header);
Set_Package_Header (New_Decl, New_Hdr);
@@ -2643,25 +2643,24 @@ package body Canon is
First, Last : Iir;
El : Iir;
Bod : Iir;
+ Orig : Iir;
begin
- First := Null_Iir;
- Last := Null_Iir; -- Kill the warning
+ Sub_Chain_Init (First, Last);
El := Get_Declaration_Chain (Decl);
while Is_Valid (El) loop
- if Get_Kind (El) = Iir_Kind_Package_Declaration
- and then Get_Need_Body (El)
- and then Get_Package_Origin (El) /= Null_Iir
- then
- Bod := Sem_Inst.Instantiate_Package_Body (El);
- Set_Parent (Bod, Parent);
+ if Get_Kind (El) = Iir_Kind_Package_Declaration then
+ Orig := Get_Package_Origin (El);
+ if Orig /= Null_Iir
+ and then Get_Need_Body (Get_Uninstantiated_Package_Decl (Orig))
+ then
+ -- That's a package instantiation of a package that needs a
+ -- body. Therefore, the instantiation also needs a body.
+ -- Create it.
+ Bod := Sem_Inst.Instantiate_Package_Body (El);
+ Set_Parent (Bod, Parent);
- -- Append.
- if First = Null_Iir then
- First := Bod;
- else
- Set_Chain (Last, Bod);
+ Sub_Chain_Append (First, Last, Bod);
end if;
- Last := Bod;
end if;
El := Get_Chain (El);
end loop;
diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb
index 28883babb..4d25fd77e 100644
--- a/src/vhdl/translate/trans-chap12.adb
+++ b/src/vhdl/translate/trans-chap12.adb
@@ -711,7 +711,9 @@ package body Trans.Chap12 is
Lib_Unit := Get_Library_Unit (Unit);
case Get_Kind (Lib_Unit) is
when Iir_Kind_Package_Declaration =>
- if not Get_Elab_Flag (Unit) then
+ if not Get_Elab_Flag (Unit)
+ and then Get_Package_Origin (Lib_Unit) = Null_Iir
+ then
Chap2.Elab_Package_Body (Lib_Unit, Null_Iir);
end if;
when Iir_Kind_Entity_Declaration =>
diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb
index 1a4703f95..bc69661bb 100644
--- a/src/vhdl/translate/translation.adb
+++ b/src/vhdl/translate/translation.adb
@@ -289,6 +289,12 @@ package body Translation is
New_Debug_Comment_Decl
("package declaration " & Image_Identifier (Lib_Unit));
Chap2.Translate_Package_Declaration (Lib_Unit);
+ if Get_Package_Origin (Lib_Unit) /= Null_Iir
+ and then Get_Package_Body (Lib_Unit) /= Null_Iir
+ then
+ -- Corresponding body for package instantiation.
+ Chap2.Translate_Package_Body (Get_Package_Body (Lib_Unit));
+ end if;
when Iir_Kind_Package_Body =>
New_Debug_Comment_Decl
("package body " & Image_Identifier (Lib_Unit));