aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-10-01 19:15:06 +0200
committerTristan Gingold <tgingold@free.fr>2021-10-01 19:15:06 +0200
commitedb8566e50c6c6041cb31006ed4c11c7adb2831d (patch)
treefda59ca1ad13b18a16d1c254a869da56ddbcb1ab /src
parentc6a66177de52ea5dc83582c24151e8ef7e86a266 (diff)
downloadghdl-edb8566e50c6c6041cb31006ed4c11c7adb2831d.tar.gz
ghdl-edb8566e50c6c6041cb31006ed4c11c7adb2831d.tar.bz2
ghdl-edb8566e50c6c6041cb31006ed4c11c7adb2831d.zip
vhdl: report unused types and subtypes
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/vhdl-sem_decls.adb4
-rw-r--r--src/vhdl/vhdl-sem_names.adb10
2 files changed, 13 insertions, 1 deletions
diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb
index f79f0def0..f7b57f601 100644
--- a/src/vhdl/vhdl-sem_decls.adb
+++ b/src/vhdl/vhdl-sem_decls.adb
@@ -2529,7 +2529,9 @@ package body Vhdl.Sem_Decls is
end if;
when Iir_Kind_Signal_Declaration
| Iir_Kind_Variable_Declaration
- | Iir_Kind_Component_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);
diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb
index fb935be34..566932049 100644
--- a/src/vhdl/vhdl-sem_names.adb
+++ b/src/vhdl/vhdl-sem_names.adb
@@ -919,6 +919,7 @@ package body Vhdl.Sem_Names is
is
Atype : Iir;
Res : Iir;
+ Decl : Iir;
begin
-- The name must not have been analyzed.
pragma Assert (Get_Type (Name) = Null_Iir);
@@ -965,6 +966,15 @@ package body Vhdl.Sem_Names is
Set_Type (Res, Atype);
+ if Get_Kind (Res) in Iir_Kinds_Denoting_Name then
+ Decl := Get_Named_Entity (Res);
+ if Kind_In (Decl,
+ Iir_Kind_Type_Declaration, Iir_Kind_Subtype_Declaration)
+ then
+ Set_Use_Flag (Decl, True);
+ end if;
+ end if;
+
return Res;
end Sem_Type_Mark;