https://gcc.gnu.org/g:c2a14d071f1fd9a640e33e272f57a7425deec3a2

commit r16-6618-gc2a14d071f1fd9a640e33e272f57a7425deec3a2
Author: Gary Dismukes <[email protected]>
Date:   Fri Dec 5 01:00:19 2025 +0000

    ada: Compiler crash on ill-formed container indexing
    
    The compiler blows up when analyzing an illegal indexing of a container
    object (such as a vector) when the indexing expression has the form of
    a named actual parameter and the name given for the parameter does not
    match the name of the index formal of the corresponding indexing function
    that the compiler identifies for doing the generalized indexing.
    
    gcc/ada/ChangeLog:
    
            * sem_ch4.adb (Try_Container_Indexing): Conditionalize last actual 
of
            call to Error_Msg_NE to avoid blowup on N_Parameter_Association 
actuals.

Diff:
---
 gcc/ada/sem_ch4.adb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index ad560ee39792..38e013a9dc4a 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -9564,7 +9564,12 @@ package body Sem_Ch4 is
 
       if Idx_Type = Any_Type then
          Error_Msg_NE
-           ("container cannot be indexed with&", N, Etype (First (Exprs)));
+           ("container cannot be indexed with&", N,
+            (if Nkind (First (Exprs)) = N_Parameter_Association
+             then
+                Etype (Explicit_Actual_Parameter (First (Exprs)))
+             else
+                Etype (First (Exprs))));
          Rewrite (N, New_Occurrence_Of (Any_Id, Loc));
       end if;

Reply via email to