diff options
author | Gary Dismukes <dismukes@adacore.com> | 2025-01-08 22:51:41 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2025-01-13 11:52:58 +0100 |
commit | c6989fbbf2f195e874245409635a856d74bf6945 (patch) | |
tree | 534628888d0077081162344700a10e53f7642ba0 /gcc | |
parent | f9d22b7ac734a917f3ee379336ad764ccd6f74ca (diff) | |
download | gcc-c6989fbbf2f195e874245409635a856d74bf6945.zip gcc-c6989fbbf2f195e874245409635a856d74bf6945.tar.gz gcc-c6989fbbf2f195e874245409635a856d74bf6945.tar.bz2 |
ada: Unbounded recursion on character aggregates with predicated component subtype
The compiler was recursing endlessly when analyzing an aggregate of
an array type whose component subtype has a static predicate and the
component expressions are static, repeatedly transforming the aggregate
first into a string literal and then back into an aggregate. This is fixed
by suppressing the transformation to a string literal in the case where
the component subtype has predicates.
gcc/ada/ChangeLog:
* sem_aggr.adb (Resolve_Aggregate): Add another condition to prevent rewriting
an aggregate whose type is an array of characters, testing for the presence of
predicates on the component type.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_aggr.adb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 095093c..f6db5cb 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -1382,11 +1382,11 @@ package body Sem_Aggr is -- Do not perform this transformation if this was a string literal -- to start with, whose components needed constraint checks, or if - -- the component type is non-static, because it will require those - -- checks and be transformed back into an aggregate. If the index - -- type is not Integer the aggregate may represent a user-defined - -- string type but the context might need the original type so we - -- do not perform the transformation at this point. + -- the component type is nonstatic or has predicates, because it will + -- require those checks and be transformed back into an aggregate. + -- If the index type is not Integer, then the aggregate may represent + -- a user-defined string type but the context might need the original + -- type, so we do not perform the transformation at this point. if Number_Dimensions (Typ) = 1 and then Is_Standard_Character_Type (Component_Type (Typ)) @@ -1396,6 +1396,7 @@ package body Sem_Aggr is and then not Is_Bit_Packed_Array (Typ) and then Nkind (Original_Node (Parent (N))) /= N_String_Literal and then Is_OK_Static_Subtype (Component_Type (Typ)) + and then not Has_Predicates (Component_Type (Typ)) and then Base_Type (Etype (First_Index (Typ))) = Base_Type (Standard_Integer) and then not Has_Static_Empty_Array_Bounds (Typ) |