diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-12-12 10:03:39 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-12-12 10:03:39 +0000 |
commit | 93350089be1a068328192eb1a89f232099d0f0c7 (patch) | |
tree | 963086917c9710b288a0b8a0b05ebf812095c049 | |
parent | 0f5abd21483aeddbaa3dcd475ac0c686d835772e (diff) | |
download | gcc-93350089be1a068328192eb1a89f232099d0f0c7.zip gcc-93350089be1a068328192eb1a89f232099d0f0c7.tar.gz gcc-93350089be1a068328192eb1a89f232099d0f0c7.tar.bz2 |
[Ada] Missing dereference in bound of slice in element iterator
2019-12-12 Ed Schonberg <schonberg@adacore.com>
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
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/sem_ch5.adb | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d859109..11eca2c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,14 @@ 2019-12-12 Ed Schonberg <schonberg@adacore.com> + * 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 <schonberg@adacore.com> + * sem_ch8.adb: Improve error message for dispatching subprogram formals. diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 3abaa8d..a65e92c 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, |