From: Eric Botcazou <[email protected]>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
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 914df9d8d48..08ee37547fb 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 180bd30c0df..1ada2512377 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;
--
2.53.0