aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_expr.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-14 18:50:22 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-15 09:47:13 +0100
commit5b59dda84a7eb8a48e94a75b9b3ad008514089ce (patch)
tree7d8bcf6addec0f6ebb6bb68b50650d03607128c8 /src/vhdl/vhdl-sem_expr.adb
parent1fe5958609b57e7d134e0cc75713c530339a86dd (diff)
downloadghdl-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_expr.adb')
-rw-r--r--src/vhdl/vhdl-sem_expr.adb9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb
index 5fbb6cd34..d605d3b46 100644
--- a/src/vhdl/vhdl-sem_expr.adb
+++ b/src/vhdl/vhdl-sem_expr.adb
@@ -1262,6 +1262,15 @@ package body Vhdl.Sem_Expr is
Set_Function_Call_Staticness (Expr, Imp);
Sem_Decls.Mark_Subprogram_Used (Imp);
+ -- Check the subprogram is not called before its elaboration.
+ if not Unelaborated_Use_Allowed
+ and then Get_Kind (Imp) in Iir_Kinds_Subprogram_Declaration
+ and then not Get_Elaborated_Flag (Imp)
+ then
+ Warning_Msg_Sem (Warnid_Elaboration, +Expr,
+ "%n is called before elaborated of its body", +Imp);
+ end if;
+
-- Check purity/wait/passive.
if Subprg = Null_Iir then