When a formal generic type is marked as Ghost, the instantiation of that
generic will contain a generic subtype for the actual with the Ghost
pragma. Recognize this case.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_prag.adb (Analyze_Pragma): Recognize a generated subtype
with Ghost pragma for generic instantiations.
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -16999,6 +16999,16 @@ package body Sem_Prag is
then
Id := Defining_Entity (Stmt);
exit;
+
+ -- When pragma Ghost applies to a generic formal type, the
+ -- type declaration in the instantiation is a generated
+ -- subtype declaration.
+
+ elsif Nkind (Stmt) = N_Subtype_Declaration
+ and then Present (Generic_Parent_Type (Stmt))
+ then
+ Id := Defining_Entity (Stmt);
+ exit;
end if;
-- The pragma applies to a legal construct, stop the traversal