diff options
Diffstat (limited to 'gcc/ada/exp_aggr.adb')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 581e31c..e2313f2 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -5537,13 +5537,29 @@ package body Exp_Aggr is Get_Index_Bounds (Obj_In, Obj_Lo, Obj_Hi); if not Compile_Time_Known_Value (Aggr_Lo) - or else not Compile_Time_Known_Value (Aggr_Hi) or else not Compile_Time_Known_Value (Obj_Lo) or else not Compile_Time_Known_Value (Obj_Hi) or else Expr_Value (Aggr_Lo) /= Expr_Value (Obj_Lo) - or else Expr_Value (Aggr_Hi) /= Expr_Value (Obj_Hi) then return False; + + -- For an assignment statement we require static matching + -- of bounds. Ditto for an allocator whose qualified + -- expression is a constrained type. If the expression in + -- the allocator is an unconstrained array, we accept an + -- upper bound that is not static, to allow for non-static + -- expressions of the base type. Clearly there are further + -- possibilities (with diminishing returns) for safely + -- building arrays in place here. + + elsif Nkind (Parent (N)) = N_Assignment_Statement + or else Is_Constrained (Etype (Parent (N))) + then + if not Compile_Time_Known_Value (Aggr_Hi) + or else Expr_Value (Aggr_Hi) /= Expr_Value (Obj_Hi) + then + return False; + end if; end if; Next_Index (Aggr_In); |