From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Richard Kenner <kenner@adacore.com>
Subject: [Ada] Don't allow entry in implicit with chain to be ghost
Date: Thu, 2 Dec 2021 16:28:46 +0000 [thread overview]
Message-ID: <20211202162846.GA2157510@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 345 bytes --]
When we add an entry to the implicit with chain of a unit while adding
an RTS unit, we must not mark it as a ignored ghost statement because it
points to the next with in the chain.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* rtsfind.adb (Maybe_Add_With): Ensure that the added "with" is
never marked as ignored ghost code.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1322 bytes --]
diff --git a/gcc/ada/rtsfind.adb b/gcc/ada/rtsfind.adb
--- a/gcc/ada/rtsfind.adb
+++ b/gcc/ada/rtsfind.adb
@@ -1248,9 +1248,10 @@ package body Rtsfind is
-- for this unit to the current compilation unit.
declare
- LibUnit : constant Node_Id := Unit (Cunit (U.Unum));
- Clause : Node_Id;
- Withn : Node_Id;
+ LibUnit : constant Node_Id := Unit (Cunit (U.Unum));
+ Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
+ Clause : Node_Id;
+ Withn : Node_Id;
begin
Clause := U.First_Implicit_With;
@@ -1262,11 +1263,18 @@ package body Rtsfind is
Clause := Next_Implicit_With (Clause);
end loop;
+ -- We want to make sure that the "with" we create below isn't
+ -- marked as ignored ghost code because this list may be walked
+ -- later, after ignored ghost code is converted to a null
+ -- statement.
+
+ Ghost_Mode := None;
Withn :=
Make_With_Clause (Standard_Location,
Name =>
Make_Unit_Name
(U, Defining_Unit_Name (Specification (LibUnit))));
+ Ghost_Mode := Saved_GM;
Set_Corresponding_Spec (Withn, U.Entity);
Set_First_Name (Withn);
reply other threads:[~2021-12-02 16:28 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=20211202162846.GA2157510@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kenner@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).