From: Ed Schonberg Date: Thu, 12 Dec 2019 10:03:39 +0000 (+0000) Subject: [Ada] Missing dereference in bound of slice in element iterator X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=93350089be1a068328192eb1a89f232099d0f0c7;p=gcc.git [Ada] Missing dereference in bound of slice in element iterator 2019-12-12 Ed Schonberg gcc/ada/ * sem_ch5.adb: (Analyze_Iterator_Specification): If the iteration is over a slice, complete the resolution of its bounds, which may be aebitrary expressions. The previous pre-analysis may have created itypes for the slice but has not performed the expansion that for example may introduce actions that specify explicit dereferences and run-time checks. From-SVN: r279302 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d859109a030..11eca2c3dc7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2019-12-12 Ed Schonberg + + * sem_ch5.adb: (Analyze_Iterator_Specification): If the + iteration is over a slice, complete the resolution of its + bounds, which may be aebitrary expressions. The previous + pre-analysis may have created itypes for the slice but has not + performed the expansion that for example may introduce actions + that specify explicit dereferences and run-time checks. + 2019-12-12 Ed Schonberg * sem_ch8.adb: Improve error message for dispatching subprogram diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 3abaa8dd836..a65e92c0b1b 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -2343,6 +2343,27 @@ package body Sem_Ch5 is Check_Reverse_Iteration (Typ); end if; + -- For an element iteration over a slice, we must complete + -- the resolution and expansion of the slice bounds. These + -- can be arbitrary expressions, and the preanalysis that + -- was performed in preparation for the iteration may have + -- generated an itype whose bounds must be fully expanded. + -- We set the parent node to provide a proper insertion + -- point for generated actions, if any. + + if Nkind (Iter_Name) = N_Slice + and then Nkind (Discrete_Range (Iter_Name)) = N_Range + and then not Analyzed (Discrete_Range (Iter_Name)) + then + declare + Indx : constant Node_Id := + Entity (First_Index (Etype (Iter_Name))); + begin + Set_Parent (Indx, Iter_Name); + Resolve (Scalar_Range (Indx), Etype (Indx)); + end; + end if; + -- The name in the renaming declaration may be a function call. -- Indicate that it does not come from source, to suppress -- spurious warnings on renamings of parameterless functions,