[Ada] Fix search for "for ... of" loop subprograms
authorBob Duff <duff@adacore.com>
Mon, 2 May 2022 18:11:03 +0000 (14:11 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 1 Jun 2022 08:43:17 +0000 (08:43 +0000)
commit3c2674cc0d725783a501a78cdc1256642448c159
treea2d0bb030119223ba9049c9e0f581efba0648235
parentc97f3a7dc230dab0877d0c27b84eb06132cf7bf8
[Ada] Fix search for "for ... of" loop subprograms

This patch makes the search for Get_Element_Access, Step (Next/Prev),
Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of"
loops) more robust.  In particular, we have a new Next procedure in Ada
2022, and we need to pick the right one.

We have not yet added the new Next and other subprograms.

gcc/ada/

* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): For each
subprogram found, assert that the variable is Empty, so we can
detect bugs where we find two or more things with the same name.
Without this patch, that bug would happen when we add the new
Next procedure.  For Step, make sure we pick the right one, by
checking name and number of parameters.  For Get_Element_Access,
check that we're picking a function.  That's not really
necessary, because there is no procedure with that name, but it
seems cleaner this way.
* rtsfind.ads: Minor comment improvement. It seems kind of odd
to say "under no circumstances", and then immediately contradict
that with "The one exception is...".
gcc/ada/exp_ch5.adb
gcc/ada/rtsfind.ads