From 6c6a053898b751112e268907b164e970b0a6154e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 17 Nov 2017 06:36:28 +0100 Subject: Fix incorrect analysis message on unbounded array. For #459 --- src/vhdl/sem_types.adb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/vhdl/sem_types.adb b/src/vhdl/sem_types.adb index aed9942cf..45f67be51 100644 --- a/src/vhdl/sem_types.adb +++ b/src/vhdl/sem_types.adb @@ -1498,16 +1498,22 @@ package body Sem_Types is -- array type with no index constraint applying to the index -- subtypes, or an access type whose designated type is such -- a type. - if Get_Kind (Type_Mark) = Iir_Kind_Array_Subtype_Definition - and then Get_Index_Constraint_Flag (Type_Mark) - then - Error_Msg_Sem (+Def, "constrained array cannot be re-constrained"); - end if; if Subtype_Index_List = Null_Iir_Flist then - -- Array is not constrained. - Set_Index_Constraint_Flag (Def, False); + -- Array is not constrained, but the type mark may already have + -- constrained on indexes. + if Get_Kind (Type_Mark) = Iir_Kind_Array_Subtype_Definition then + Set_Index_Constraint_Flag + (Def, Get_Index_Constraint_Flag (Type_Mark)); + else + Set_Index_Constraint_Flag (Def, False); + end if; Set_Index_Subtype_List (Def, Type_Index_List); else + if Get_Kind (Type_Mark) = Iir_Kind_Array_Subtype_Definition + and then Get_Index_Constraint_Flag (Type_Mark) + then + Error_Msg_Sem (+Def, "constrained array cannot be re-constrained"); + end if; Type_Nbr_Dim := Get_Nbr_Elements (Type_Index_List); Subtype_Nbr_Dim := Get_Nbr_Elements (Subtype_Index_List); -- cgit v1.2.3