From ecbca396df7cb437e9ed112cdf0c5c2035d43885 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 16 Dec 2022 07:44:22 +0100 Subject: synth-vhdl_stmts: handle impure functions. Fix #2270 --- src/synth/synth-vhdl_stmts.adb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb index 8c521cc77..5268e28d8 100644 --- a/src/synth/synth-vhdl_stmts.adb +++ b/src/synth/synth-vhdl_stmts.adb @@ -2623,7 +2623,14 @@ package body Synth.Vhdl_Stmts is if Is_Error (Sub_Inst) then Res := No_Valtyp; else - if not Is_Func then + -- If the subprogram is not pure, clear the const flag. + if Is_Func then + -- For functions. + if Ctxt /= null and then not Get_Pure_Flag (Imp) then + Set_Instance_Const (Sub_Inst, False); + end if; + else + -- For procedures. if Ctxt /= null and then Get_Purity_State (Imp) /= Pure then Set_Instance_Const (Sub_Inst, False); end if; -- cgit v1.2.3