https://gcc.gnu.org/g:071d1cbad22d78ea452e870cbce7d3b0a16dc0d4
commit r17-1364-g071d1cbad22d78ea452e870cbce7d3b0a16dc0d4 Author: Eric Botcazou <[email protected]> Date: Wed May 27 13:03:51 2026 +0200 ada: Robustify error recovery of structural instantiation in generic formal part The previous attempt didn't address the root cause of the cascading errors, so this rewinds it and starts from scratch. gcc/ada/ChangeLog: * sem_ch3.adb (Analyze_Private_Extension_Declaration): Revert latest change. (Find_Type_Of_Subtype_Indic): Return Any_Type if Find_Type fails to resolve the type. * sem_ch12.adb (Analyze_Formal_Derived_Type): Restore more specific error recovery path. Diff: --- gcc/ada/sem_ch12.adb | 5 +++-- gcc/ada/sem_ch3.adb | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 914df9d8d489..08ee37547fbe 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -3220,8 +3220,9 @@ package body Sem_Ch12 is end if; end if; - if Serious_Errors_Detected > 0 then - -- avoid passing bad argument to Entity + if not Is_Entity_Name (Subtype_Mark (Def)) then + pragma Assert (Serious_Errors_Detected > 0); + -- Avoid passing bad argument to Entity return; end if; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 180bd30c0df5..1ada25123776 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5578,11 +5578,6 @@ package body Sem_Ch3 is end if; Parent_Type := Find_Type_Of_Subtype_Indic (Indic); - if No (Parent_Type) then - pragma Assert (Serious_Errors_Detected > 0); - goto Leave; - end if; - Parent_Base := Base_Type (Parent_Type); if Parent_Type = Any_Type or else Etype (Parent_Type) = Any_Type then @@ -19305,6 +19300,11 @@ package body Sem_Ch3 is else Find_Type (S); + if not Is_Entity_Name (S) then + pragma Assert (Serious_Errors_Detected > 0); + -- Avoid passing bad argument to Entity + return Any_Type; + end if; Typ := Entity (S); end if;
