diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2e302299660..b3e94dbf5dc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-09-19 Bob Duff + + * sem_attr.adb (Resolve_Attribute): Make sure the secondary + stack is properly managed in the case of a 'Range attribute in a + loop. + 2019-09-19 Raphael Amiard * libgnat/a-cfhase.ads (Set): Add comments to public primitives. diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 4c6cba65a44..95de2e4fef4 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -11570,6 +11570,16 @@ package body Sem_Attr is begin if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then Resolve (P); + + -- If the prefix is a function call returning on the secondary + -- stack, we must make sure to mark/release the stack. + + if Nkind (P) = N_Function_Call + and then Nkind (Parent (N)) = N_Loop_Parameter_Specification + and then Requires_Transient_Scope (Etype (P)) + then + Set_Uses_Sec_Stack (Scope (Current_Scope)); + end if; end if; Dims := Expressions (N);