From 6ee12be2bd560a9b50f40d501b443759d204230a Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 20 Apr 2020 18:00:40 +0200 Subject: translate: fix handling of nested generic package. Fix #1246 --- src/vhdl/translate/trans-chap2.adb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 84fa35a94..6016a4c6e 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -1299,17 +1299,20 @@ package body Trans.Chap2 is Instantiate_Var (Src.Package_Instance_Body_Var), Package_Instance_Elab_Subprg => Src.Package_Instance_Elab_Subprg, - Package_Instance_Spec_Scope => - Instantiate_Var_Scope (Src.Package_Instance_Spec_Scope), + Package_Instance_Spec_Scope => Null_Var_Scope, Package_Instance_Body_Scope => Instantiate_Var_Scope (Src.Package_Instance_Body_Scope)); - Push_Instantiate_Var_Scope - (Dest.Package_Instance_Spec_Scope'Access, - Src.Package_Instance_Spec_Scope'Access); + -- The body scope needs to be instantiated before instantiating + -- the spec scope, as the spec scope is a field of the body + -- scope. Push_Instantiate_Var_Scope (Dest.Package_Instance_Body_Scope'Access, Src.Package_Instance_Body_Scope'Access); - + Dest.Package_Instance_Spec_Scope := + Instantiate_Var_Scope (Src.Package_Instance_Spec_Scope); + Push_Instantiate_Var_Scope + (Dest.Package_Instance_Spec_Scope'Access, + Src.Package_Instance_Spec_Scope'Access); when Kind_Field => Dest.all := (Kind => Kind_Field, Mark => False, @@ -1358,10 +1361,12 @@ package body Trans.Chap2 is null; end case; when Kind_Package_Instance => - Pop_Instantiate_Var_Scope - (Info.Package_Instance_Body_Scope'Access); + -- The order is important: it must be the reverse order of the + -- push. Pop_Instantiate_Var_Scope (Info.Package_Instance_Spec_Scope'Access); + Pop_Instantiate_Var_Scope + (Info.Package_Instance_Body_Scope'Access); when others => null; end case; -- cgit v1.2.3