From 5c6d5048c222e06cab457dc5f2dc9035bd9a05d6 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 1 May 2023 10:11:41 +0200 Subject: vhdl-sem_expr: adjust check of aggregate range For #2422 --- src/vhdl/vhdl-sem_expr.adb | 8 +++++++- src/vhdl/vhdl-sem_expr.ads | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index be60e12c8..95842c903 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -3863,15 +3863,21 @@ package body Vhdl.Sem_Expr is Expr_Staticness : Iir_Staticness; Info : Array_Aggr_Info renames Infos (Dim); + + Is_Sub_Range : Boolean; begin -- Analyze choices (for aggregate but not for strings). if Get_Kind (Aggr) = Iir_Kind_Aggregate then -- By default, consider the aggregate can be statically built. Set_Aggregate_Expand_Flag (Aggr, True); + -- True if the aggregate (and not the context) defines its range. + Is_Sub_Range := + not (Constrained and then Get_Index_Constraint_Flag (A_Type)); + Assoc_Chain := Get_Association_Choices_Chain (Aggr); Sem_Choices_Range (Assoc_Chain, Index_Type, Low, High, - Get_Location (Aggr), not Constrained, False); + Get_Location (Aggr), Is_Sub_Range, False); Set_Association_Choices_Chain (Aggr, Assoc_Chain); -- Update infos. diff --git a/src/vhdl/vhdl-sem_expr.ads b/src/vhdl/vhdl-sem_expr.ads index 19b817e67..4c9f11695 100644 --- a/src/vhdl/vhdl-sem_expr.ads +++ b/src/vhdl/vhdl-sem_expr.ads @@ -205,9 +205,8 @@ package Vhdl.Sem_Expr is -- Check that the values of CHOICE_CHAIN are a continuous range, and -- extract the lower LOW and upper HIGH bound (useful to create the -- corresponding subtype). The values must be of type SUB_TYPE, and if - -- IS_SUB_RANGE True, they must be within SUB_TYPE. + -- IS_SUB_RANGE is False, they must be within SUB_TYPE. -- The choices must be locally static. - -- If REORDER_CHOICES is true, CHOICE_CHAIN is ordered. procedure Sem_Check_Continuous_Choices (Choice_Chain : Iir; Choice_Type : Iir; Low : out Iir; -- cgit v1.2.3