public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1664] [Ada] Fix incorrect handling of Ghost aspect
Date: Wed, 13 Jul 2022 10:03:26 +0000 (GMT)	[thread overview]
Message-ID: <20220713100326.E77923838A8E@sourceware.org> (raw)

https://gcc.gnu.org/g:8e3030ea9ae79880850c821887c9aa06a76ac21b

commit r13-1664-g8e3030ea9ae79880850c821887c9aa06a76ac21b
Author: Yannick Moy <moy@adacore.com>
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


                 reply	other threads:[~2022-07-13 10:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220713100326.E77923838A8E@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).