From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ronan Desplanques <desplanques@adacore.com>
Subject: [COMMITTED] ada: Fix pragma Compile_Time_Error and -gnatdJ crash
Date: Tue, 14 May 2024 10:23:50 +0200 [thread overview]
Message-ID: <20240514082350.834099-1-poulhies@adacore.com> (raw)
From: Ronan Desplanques <desplanques@adacore.com>
This patch makes it so the diagnostics coming from occurrences of
pragma Compile_Time_Error and Compile_Time_Warning are emitted with
a node parameter so they don't cause a crash when -gnatdJ is enabled.
gcc/ada/
* errout.ads (Error_Msg): Add node parameter.
* errout.adb (Error_Msg): Add parameter and pass it to
the underlying call.
* sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): Pass
pragma node when emitting errors.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/errout.adb | 3 ++-
gcc/ada/errout.ads | 7 ++++---
gcc/ada/sem_prag.adb | 8 ++++----
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 4622290897b..f10539d0949 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -325,12 +325,13 @@ package body Errout is
procedure Error_Msg
(Msg : String;
Flag_Location : Source_Ptr;
+ N : Node_Id;
Is_Compile_Time_Pragma : Boolean)
is
Save_Is_Compile_Time_Msg : constant Boolean := Is_Compile_Time_Msg;
begin
Is_Compile_Time_Msg := Is_Compile_Time_Pragma;
- Error_Msg (Msg, To_Span (Flag_Location), Current_Node);
+ Error_Msg (Msg, To_Span (Flag_Location), N);
Is_Compile_Time_Msg := Save_Is_Compile_Time_Msg;
end Error_Msg;
diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
index 089da867d45..f0e3f5d0b7c 100644
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -738,10 +738,11 @@ package Errout is
procedure Error_Msg
(Msg : String;
Flag_Location : Source_Ptr;
+ N : Node_Id;
Is_Compile_Time_Pragma : Boolean);
- -- Same as Error_Msg (String, Source_Ptr) except Is_Compile_Time_Pragma
- -- lets the caller specify whether this is a Compile_Time_Warning or
- -- Compile_Time_Error pragma.
+ -- Same as Error_Msg (String, Source_Ptr, Node_Id) except
+ -- Is_Compile_Time_Pragma lets the caller specify whether this is a
+ -- Compile_Time_Warning or Compile_Time_Error pragma.
procedure Error_Msg_S (Msg : String);
-- Output a message at current scan pointer location. This routine can be
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index dfc415da3f3..9646e891c46 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -33145,11 +33145,11 @@ package body Sem_Prag is
if Force then
if Cont = False then
Error_Msg
- ("<<~!!", Eloc, Is_Compile_Time_Pragma => True);
+ ("<<~!!", Eloc, N, Is_Compile_Time_Pragma => True);
Cont := True;
else
Error_Msg
- ("\<<~!!", Eloc, Is_Compile_Time_Pragma => True);
+ ("\<<~!!", Eloc, N, Is_Compile_Time_Pragma => True);
end if;
-- Error, rather than warning, or in a body, so we do not
@@ -33161,11 +33161,11 @@ package body Sem_Prag is
else
if Cont = False then
Error_Msg
- ("<<~", Eloc, Is_Compile_Time_Pragma => True);
+ ("<<~", Eloc, N, Is_Compile_Time_Pragma => True);
Cont := True;
else
Error_Msg
- ("\<<~", Eloc, Is_Compile_Time_Pragma => True);
+ ("\<<~", Eloc, N, Is_Compile_Time_Pragma => True);
end if;
end if;
--
2.43.2
reply other threads:[~2024-05-14 8:23 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=20240514082350.834099-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=desplanques@adacore.com \
--cc=gcc-patches@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).