diff options
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r-- | gcc/ada/sem_attr.adb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index fd72ba080d5..bab1802ec3a 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -5258,7 +5258,7 @@ package body Sem_Attr is if Present (AS) and then Is_Constrained (AS) then P_Entity := AS; - -- If we have an unconstrained type, cannot fold + -- If we have an unconstrained type we cannot fold else Check_Expressions; @@ -5517,6 +5517,9 @@ package body Sem_Attr is -- an optimization, but it falls out essentially free, so why not. -- Again we compute the variable Static for easy reference later -- (note that no array attributes are static in Ada 83). + -- we also need to set Static properly for subsequent legality checks + -- which might otherwise accept non-static constants in contexts + -- where they are not legal. Static := Ada_Version >= Ada_95 and then Statically_Denotes_Entity (P); @@ -5526,6 +5529,16 @@ package body Sem_Attr is begin N := First_Index (P_Type); + + -- The expression is static if the array type is constrained + -- by given bounds, and not by an initial expression. Constant + -- strings are static in any case. + + if Root_Type (P_Type) /= Standard_String then + Static := + Static and then not Is_Constr_Subt_For_U_Nominal (P_Type); + end if; + while Present (N) loop Static := Static and then Is_Static_Subtype (Etype (N)); |