From 3ed03181ff403e2805d36c425b1e3aa5725fe3d7 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 14 Jan 2023 19:58:35 +0100 Subject: vhdl-sem.adb: also check elaboration status within package bodies --- src/vhdl/vhdl-sem.adb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/vhdl/vhdl-sem.adb b/src/vhdl/vhdl-sem.adb index cd4267c71..8938ec3c7 100644 --- a/src/vhdl/vhdl-sem.adb +++ b/src/vhdl/vhdl-sem.adb @@ -2890,8 +2890,10 @@ package body Vhdl.Sem is return False; end Is_Package_Macro_Expanded; - -- Mark declarations of HDR as elaborated. - procedure Mark_Declarations_Elaborated (Hdr : Iir) + -- Mark declarations of HDR elaboration status to FLAG. + -- Set to true at then end of a package declaration, but reset at the + -- beginning of body analysis. + procedure Mark_Declarations_Elaborated (Hdr : Iir; Flag : Boolean) is Decl : Iir; begin @@ -2899,7 +2901,14 @@ package body Vhdl.Sem is while Decl /= Null_Iir loop case Get_Kind (Decl) is when Iir_Kinds_Subprogram_Declaration => - Set_Elaborated_Flag (Decl, True); + -- The flag can always be set, but not cleared on implicit + -- subprograms. + if Flag + or else + Get_Implicit_Definition (Decl) not in Iir_Predefined_Implicit + then + Set_Elaborated_Flag (Decl, Flag); + end if; when Iir_Kind_Type_Declaration => declare Def : constant Iir := Get_Type_Definition (Decl); @@ -2907,8 +2916,8 @@ package body Vhdl.Sem is if Get_Kind (Def) = Iir_Kind_Protected_Type_Declaration then -- Mark the protected type as elaborated. -- Mark the methods as elaborated. - Set_Elaborated_Flag (Def, True); - Mark_Declarations_Elaborated (Def); + Set_Elaborated_Flag (Def, Flag); + Mark_Declarations_Elaborated (Def, Flag); end if; end; when others => @@ -2992,7 +3001,7 @@ package body Vhdl.Sem is end if; Sem_Declaration_Chain (Pkg); - Mark_Declarations_Elaborated (Pkg); + Mark_Declarations_Elaborated (Pkg, True); -- GHDL: subprogram bodies appear in package body. Pop_Signals_Declarative_Part (Implicit); @@ -3078,6 +3087,10 @@ package body Vhdl.Sem is Set_Package_Body (Package_Decl, Decl); Set_Is_Within_Flag (Package_Decl, True); + -- Unmark subprograms from the specifications: they are not elaborated + -- before body elaboration. + Mark_Declarations_Elaborated (Package_Decl, False); + -- LRM93 10.1 Declarative Region -- 4. A package declaration, together with the corresponding -- body (if any). -- cgit v1.2.3