When handling deferred references, if an actual that is the prefix of an enclosing prefixed call has been rewritten, we must use Nkind and Sloc to identify the corresponding formal. The First_Named_Actual of the enclosing call may be meaningless after the surrounding expansion.
No simple example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-05-21 Ed Schonberg <schonb...@adacore.com> * sem_util.adb (Find_Actual): If an actual that is the prefix of an enclosing prefixed call has been rewritten, use Nkind and Sloc to identify the corresponding formal, when handling deferred references.
Index: sem_util.adb =================================================================== --- sem_util.adb (revision 210687) +++ sem_util.adb (working copy) @@ -5518,6 +5518,16 @@ while Present (Formal) and then Present (Actual) loop if Actual = N then return; + + -- An actual that is the prefix in a prefixed call may have + -- been rewritten in the call, after the deferred reference + -- was collected. Check if sloc and kinds match. + + elsif Sloc (Actual) = Sloc (N) + and then Nkind (Actual) = Nkind (N) + then + return; + else Actual := Next_Actual (Actual); Formal := Next_Formal (Formal);