From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Yannick Moy <moy@adacore.com>
Subject: [Ada] Issue advice for error regarding Old/Loop_Entry on unevaluated expr.
Date: Thu, 26 Nov 2020 03:41:00 -0500 [thread overview]
Message-ID: <20201126084100.GA20507@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
Ada puts some restrictions on the use of attributes Old, that SPARK
mimics for attribute Loop_Entry, inside a "potentially unevaluated
context". These restrictions can be lifted by using pragma
Unevaluated_Use_Of_Old with argument Allow. Issue a message to indicate
that to the user.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_attr.adb (Analyze_Attribute): Issue a continuation message
to give proper recommendation here.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1774 bytes --]
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -420,9 +420,11 @@ package body Sem_Attr is
-- no arguments is used when the caller has already generated the
-- required error messages.
- procedure Error_Attr_P (Msg : String);
+ procedure Error_Attr_P (Msg : String; Msg_Cont : String := "");
pragma No_Return (Error_Attr_P);
- -- Like Error_Attr, but error is posted at the start of the prefix
+ -- Like Error_Attr, but error is posted at the start of the prefix. The
+ -- second message Msg_Cont is useful to issue a continuation message
+ -- before raising Bad_Attribute.
procedure Legal_Formal_Attribute;
-- Common processing for attributes Definite and Has_Discriminants.
@@ -2690,10 +2692,13 @@ package body Sem_Attr is
-- Error_Attr_P --
------------------
- procedure Error_Attr_P (Msg : String) is
+ procedure Error_Attr_P (Msg : String; Msg_Cont : String := "") is
begin
Error_Msg_Name_1 := Aname;
Error_Msg_F (Msg, P);
+ if Msg_Cont /= "" then
+ Error_Msg_F (Msg_Cont, P);
+ end if;
Error_Attr;
end Error_Attr_P;
@@ -2842,7 +2847,10 @@ package body Sem_Attr is
and then Attr_Id = Attribute_Old
then " or be eligible for conditional evaluation"
& " (RM 6.1.1 (27))"
- else ""));
+ else ""),
+ Msg_Cont =>
+ "\using pragma Unevaluated_Use_Of_Old (Allow) will make "
+ & "this legal");
when 'W' =>
Error_Msg_Name_1 := Aname;
reply other threads:[~2020-11-26 8:41 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=20201126084100.GA20507@adacore.com \
--to=derodat@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).