diff options
author | Javier Miranda <miranda@adacore.com> | 2024-12-10 19:49:15 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2025-01-06 10:14:47 +0100 |
commit | 0216cca155e8abbd711e413d5ea99f3963ab4f43 (patch) | |
tree | a3140a0eb304b5edf7abc7480147ddf4185fb05c | |
parent | 145314b3ef9017bb7d841578bb989dd85b3a12ac (diff) | |
download | gcc-0216cca155e8abbd711e413d5ea99f3963ab4f43.zip gcc-0216cca155e8abbd711e413d5ea99f3963ab4f43.tar.gz gcc-0216cca155e8abbd711e413d5ea99f3963ab4f43.tar.bz2 |
ada: Crash in prefix notation with access to class-wide object
The compiler crashes analyzing a prefix notation call when its
prefix is an access to a class-wide object, an actual parameter
is missing, and the sources are compiled with language extensions
(-gnatX) and full errors (-gnatf).
gcc/ada/ChangeLog:
* sem_ch4.adb (Try_Object_Operation): if no candidate interpretation
matches the context, redo the same analysis with Report_Error True
to report the error.
-rw-r--r-- | gcc/ada/sem_ch4.adb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 18b3a4f..94e4342 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -10498,6 +10498,11 @@ package body Sem_Ch4 is Set_Etype (Subprog, Any_Type); Set_Parent (New_Call_Node, Parent (Node_To_Replace)); + -- Perform the analysis searching for a candidate with Report_Error + -- set to False (see above); if no candidate interpretation matches + -- the context, this analysis will be redone with Report_Error set + -- to True to provide additional information. + if not Is_Overloaded (Obj) then Try_One_Prefix_Interpretation (Obj_Type); @@ -10537,18 +10542,22 @@ package body Sem_Ch4 is if All_Errors_Mode then Report_Error := True; - if Try_Primitive_Operation - (Call_Node => New_Call_Node, - Node_To_Replace => Node_To_Replace) - or else - Try_Class_Wide_Operation - (Call_Node => New_Call_Node, - Node_To_Replace => Node_To_Replace) - then - null; - end if; + if not Is_Overloaded (Obj) then + Try_One_Prefix_Interpretation (Obj_Type); + else + declare + I : Interp_Index; + It : Interp; + begin + Get_First_Interp (Obj, I, It); + while Present (It.Nam) loop + Try_One_Prefix_Interpretation (It.Typ); + Get_Next_Interp (I, It); + end loop; + end; + end if; else Analyze_One_Call (N => New_Call_Node, |