https://gcc.gnu.org/g:3b762dc6f04bf0f8613d7065267c6f2759330a61

commit r16-9069-g3b762dc6f04bf0f8613d7065267c6f2759330a61
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 40d77093ef36..58692fb8e073 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -3200,8 +3200,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 f8def8551efb..8e291534d916 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5583,11 +5583,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
@@ -19283,6 +19278,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;

Reply via email to