diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-11-01 19:50:40 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-11-01 21:11:09 +0100 |
commit | b96b6db6df514116d36e776df181582a7d1061f8 (patch) | |
tree | e59c866625f9f8eec66e006397061b8440464e19 /src/vhdl/vhdl-sem_decls.adb | |
parent | bd54ba78c09e2d6ec34b57fe3d992abced185b76 (diff) | |
download | ghdl-b96b6db6df514116d36e776df181582a7d1061f8.tar.gz ghdl-b96b6db6df514116d36e776df181582a7d1061f8.tar.bz2 ghdl-b96b6db6df514116d36e776df181582a7d1061f8.zip |
vhdl: also warns on unused enumeration literal
Diffstat (limited to 'src/vhdl/vhdl-sem_decls.adb')
-rw-r--r-- | src/vhdl/vhdl-sem_decls.adb | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb index f7b57f601..19c5ec4d7 100644 --- a/src/vhdl/vhdl-sem_decls.adb +++ b/src/vhdl/vhdl-sem_decls.adb @@ -2403,6 +2403,11 @@ package body Vhdl.Sem_Decls is procedure Check_Full_Declaration (Decls_Parent : Iir; Decl: Iir) is + procedure Warn_Unused (E : Iir) is + begin + Warning_Msg_Sem (Warnid_Unused, +E, "%n is never referenced", +E); + end Warn_Unused; + El: Iir; -- If set, emit a warning if a declaration is not used. @@ -2524,17 +2529,36 @@ package body Vhdl.Sem_Decls is and then not Is_Implicit_Subprogram (El) and then not Is_Second_Subprogram_Specification (El) then - Warning_Msg_Sem (Warnid_Unused, +El, - "%n is never referenced", +El); + Warn_Unused (El); end if; when Iir_Kind_Signal_Declaration | Iir_Kind_Variable_Declaration | Iir_Kind_Component_Declaration - | Iir_Kind_Type_Declaration | Iir_Kind_Subtype_Declaration => if not Get_Use_Flag (El) then - Warning_Msg_Sem (Warnid_Unused, +El, - "%n is never referenced", +El); + Warn_Unused (El); + end if; + when Iir_Kind_Type_Declaration => + if not Get_Use_Flag (El) then + Warn_Unused (El); + else + declare + Def : constant Iir := Get_Type_Definition (El); + Lits : Iir_Flist; + Lit : Iir; + begin + if Get_Kind (Def) + = Iir_Kind_Enumeration_Type_Definition + then + Lits := Get_Enumeration_Literal_List (Def); + for I in Flist_First .. Flist_Last (Lits) loop + Lit := Get_Nth_Element (Lits, I); + if not Get_Use_Flag (Lit) then + Warn_Unused (Lit); + end if; + end loop; + end if; + end; end if; when others => null; |