From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id E77923838A8E; Wed, 13 Jul 2022 10:03:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E77923838A8E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1664] [Ada] Fix incorrect handling of Ghost aspect X-Act-Checkin: gcc X-Git-Author: Yannick Moy X-Git-Refname: refs/heads/master X-Git-Oldrev: 4709037646e9b0aa66815f86ebf98a97eb663186 X-Git-Newrev: 8e3030ea9ae79880850c821887c9aa06a76ac21b Message-Id: <20220713100326.E77923838A8E@sourceware.org> Date: Wed, 13 Jul 2022 10:03:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 10:03:27 -0000 https://gcc.gnu.org/g:8e3030ea9ae79880850c821887c9aa06a76ac21b commit r13-1664-g8e3030ea9ae79880850c821887c9aa06a76ac21b Author: Yannick Moy Date: Tue Jul 5 12:51:25 2022 +0200 [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: --- gcc/ada/sem_prag.adb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 982fdf811c6..df3d348b3a7 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