From: Yannick Moy Date: Tue, 5 Jul 2022 10:51:25 +0000 (+0200) Subject: [Ada] Fix incorrect handling of Ghost aspect X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e3030ea9ae79880850c821887c9aa06a76ac21b;p=platform%2Fupstream%2Fgcc.git [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. --- 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