diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-14 18:50:22 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-15 09:47:13 +0100 |
commit | 5b59dda84a7eb8a48e94a75b9b3ad008514089ce (patch) | |
tree | 7d8bcf6addec0f6ebb6bb68b50650d03607128c8 /src/vhdl/vhdl-sem_types.adb | |
parent | 1fe5958609b57e7d134e0cc75713c530339a86dd (diff) | |
download | ghdl-5b59dda84a7eb8a48e94a75b9b3ad008514089ce.tar.gz ghdl-5b59dda84a7eb8a48e94a75b9b3ad008514089ce.tar.bz2 ghdl-5b59dda84a7eb8a48e94a75b9b3ad008514089ce.zip |
vhdl: add a warning to detect use before elaboration
Diffstat (limited to 'src/vhdl/vhdl-sem_types.adb')
-rw-r--r-- | src/vhdl/vhdl-sem_types.adb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_types.adb b/src/vhdl/vhdl-sem_types.adb index a6f8e0223..43f887830 100644 --- a/src/vhdl/vhdl-sem_types.adb +++ b/src/vhdl/vhdl-sem_types.adb @@ -654,6 +654,8 @@ package body Vhdl.Sem_Types is procedure Sem_Protected_Type_Body (Bod : Iir) is + Prev_Unelaborated_Use_Allowed : constant Boolean := + Unelaborated_Use_Allowed; Inter : Name_Interpretation_Type; Type_Decl : Iir; Decl : Iir; @@ -686,6 +688,7 @@ package body Vhdl.Sem_Types is and then Get_Kind (Decl) = Iir_Kind_Protected_Type_Declaration then Set_Protected_Type_Declaration (Bod, Decl); + Set_Elaborated_Flag (Decl, True); if Get_Protected_Type_Body (Decl) /= Null_Iir then Report_Start_Group; Error_Msg_Sem @@ -718,6 +721,10 @@ package body Vhdl.Sem_Types is -- body. Open_Declarative_Region; + -- The body is called when a variable is created, so possibly all + -- used constructs are elaborated. + Unelaborated_Use_Allowed := True; + if Decl /= Null_Iir then Xref_Body (Bod, Decl); Add_Protected_Type_Declarations (Decl); @@ -735,6 +742,8 @@ package body Vhdl.Sem_Types is Sem_Decls.Check_Full_Declaration (Decl, Bod); end if; + Unelaborated_Use_Allowed := Prev_Unelaborated_Use_Allowed; + Close_Declarative_Region; end Sem_Protected_Type_Body; |