Commit 93350089 by Ed Schonberg Committed by Pierre-Marie de Rodat

[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
parent 0f5abd21
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.
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment