aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-14 19:58:35 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-15 11:36:05 +0100
commit3ed03181ff403e2805d36c425b1e3aa5725fe3d7 (patch)
tree2fb0ad5817c84f84b514f472bc8af1f13f5cd6c9
parent20909195de91f9e579053f7998390b3e852e6519 (diff)
downloadghdl-3ed03181ff403e2805d36c425b1e3aa5725fe3d7.tar.gz
ghdl-3ed03181ff403e2805d36c425b1e3aa5725fe3d7.tar.bz2
ghdl-3ed03181ff403e2805d36c425b1e3aa5725fe3d7.zip
vhdl-sem.adb: also check elaboration status within package bodies
-rw-r--r--src/vhdl/vhdl-sem.adb25
1 files 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).