public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Yannick Moy <moy@adacore.com>
Subject: [COMMITTED] ada: Fix spurious error on generic state in SPARK
Date: Tue,  7 May 2024 10:00:02 +0200	[thread overview]
Message-ID: <20240507080003.36830-1-poulhies@adacore.com> (raw)

From: Yannick Moy <moy@adacore.com>

The public state of a generic package needs not be part of the state of
the enclosing unit, only the state of instantiations need to be accounted
for in the enclosing package. Now fixed.

gcc/ada/

	* sem_util.adb (Find_Placement_In_State_Space): Stop search for
	placement when reaching the public state of a generic package.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_util.adb | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 3af029fd9a3..d629c76fd47 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -9103,6 +9103,14 @@ package body Sem_Util is
                Placement := Private_State_Space;
                return;
 
+            --  The item or its enclosing package appear in the visible state
+            --  space of a generic package.
+
+            elsif Ekind (Pack_Id) = E_Generic_Package then
+               Placement := Not_In_Package;
+               Pack_Id := Empty;
+               return;
+
             --  When the item appears in the visible state space of a package,
             --  continue to climb the scope stack as this may not be the final
             --  state space.
-- 
2.43.2


                 reply	other threads:[~2024-05-07  8:00 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=20240507080003.36830-1-poulhies@adacore.com \
    --to=poulhies@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=moy@adacore.com \
    /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).