aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2022-07-05 12:51:25 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-07-13 10:01:16 +0000
commit8e3030ea9ae79880850c821887c9aa06a76ac21b (patch)
tree1429c651f58095d504b0504a786d0c81847f652a /gcc/ada
parent4709037646e9b0aa66815f86ebf98a97eb663186 (diff)
downloadgcc-8e3030ea9ae79880850c821887c9aa06a76ac21b.zip
gcc-8e3030ea9ae79880850c821887c9aa06a76ac21b.tar.gz
gcc-8e3030ea9ae79880850c821887c9aa06a76ac21b.tar.bz2
[Ada] Fix incorrect handling of Ghost aspect
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. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Recognize a generated subtype with Ghost pragma for generic instantiations.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_prag.adb10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 982fdf8..df3d348 100644
--- 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