diff options
author | Yannick Moy <moy@adacore.com> | 2022-07-05 12:51:25 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-13 10:01:16 +0000 |
commit | 8e3030ea9ae79880850c821887c9aa06a76ac21b (patch) | |
tree | 1429c651f58095d504b0504a786d0c81847f652a | |
parent | 4709037646e9b0aa66815f86ebf98a97eb663186 (diff) | |
download | gcc-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.
-rw-r--r-- | gcc/ada/sem_prag.adb | 10 |
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 |