From 2acb520468f80a77a8ee5bd05203e297db1a894f Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 11 Aug 2022 04:19:16 +0200 Subject: vhdl-sem_expr: add an error message for unbounded element aggregate. But also propagate bounds on qualified expressions. Fix #2112 --- src/vhdl/vhdl-sem_expr.adb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 2c9bd8645..ba32f69ec 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -4224,6 +4224,10 @@ package body Vhdl.Sem_Expr is Sem_Array_Aggregate_Extract_Element_Subtype (Aggr, 1, Nbr_Dim, El_Subtype); if El_Subtype = Null_Iir then + if not Constrained then + Error_Msg_Sem + (+Aggr, "no element bounds for self-determined aggregate"); + end if; El_Subtype := El_Type; else -- TODO: check constraints of elements (if El_Subtype is static) @@ -4655,13 +4659,14 @@ package body Vhdl.Sem_Expr is -- qualified expression. -- TODO: also handle unbounded subtypes, but only if this is a proper -- subtype. - case Get_Kind (N_Type) is - when Iir_Kind_Array_Type_Definition - | Iir_Kind_Record_Type_Definition => - Set_Type (Expr, Get_Type (Res)); - when others => - null; - end case; + -- FIXME: is it valid ? Try to merge bounds ? This has real + -- consequences on validity, for self-determined aggregates with + -- unbounded types: the element may become bounded. + if not Is_Fully_Constrained_Type (N_Type) + and then Is_Fully_Constrained_Type (Get_Type (Res)) + then + Set_Type (Expr, Get_Type (Res)); + end if; -- Emit a warning if the value is known not to be within the bounds. if Get_Expr_Staticness (Res) = Locally -- cgit v1.2.3