From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Hristian Kirtchev <kirtchev@adacore.com>
Subject: [Ada] Argument of pragma Depends has wrong source location
Date: Mon, 02 Mar 2015 11:07:00 -0000 [thread overview]
Message-ID: <20150302110741.GA11796@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 600 bytes --]
This patch ensures that the normalization mechanism which services aspects
or pragmas Abstract_State, Contract_State, Depends, Global, Initializes,
Refined_Depends, Refined_Global and Refined_State properly sets the
source location of the first item. No change in behavior. No reproducer
possible as this requires ASIS.
Tested on x86_64-pc-linux-gnu, committed on trunk
2015-03-02 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Ensure_Aggregate_Form):
Ensure that the name denoted by the Chars of a pragma argument
association has the proper Sloc when converted into an aggregate.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 2573 bytes --]
Index: sem_prag.adb
===================================================================
--- sem_prag.adb (revision 221103)
+++ sem_prag.adb (working copy)
@@ -5222,21 +5222,32 @@
---------------------------
procedure Ensure_Aggregate_Form (Arg : Node_Id) is
- Expr : constant Node_Id := Expression (Arg);
- Loc : constant Source_Ptr := Sloc (Expr);
- Comps : List_Id := No_List;
- Exprs : List_Id := No_List;
- Nam : Name_Id;
+ CFSD : constant Boolean := Get_Comes_From_Source_Default;
+ Expr : constant Node_Id := Expression (Arg);
+ Loc : constant Source_Ptr := Sloc (Expr);
+ Comps : List_Id := No_List;
+ Exprs : List_Id := No_List;
+ Nam : Name_Id := No_Name;
+ Nam_Loc : Source_Ptr;
- CFSD : constant Boolean := Get_Comes_From_Source_Default;
- -- Used to restore Comes_From_Source_Default
+ begin
+ -- The pragma argument is in positional form:
- begin
- if Nkind (Arg) = N_Aspect_Specification then
- Nam := No_Name;
- else
- pragma Assert (Nkind (Arg) = N_Pragma_Argument_Association);
- Nam := Chars (Arg);
+ -- pragma Depends (Nam => ...)
+ -- ^
+ -- Chars field
+
+ -- Note that the Sloc of the Chars field is the Sloc of the pragma
+ -- argument association.
+
+ if Nkind (Arg) = N_Pragma_Argument_Association then
+ Nam := Chars (Arg);
+ Nam_Loc := Sloc (Arg);
+
+ -- Remove the pragma argument name as this will be captured in the
+ -- aggregate.
+
+ Set_Chars (Arg, No_Name);
end if;
-- The argument is already in aggregate form, but the presence of a
@@ -5279,17 +5290,10 @@
else
Comps := New_List (
Make_Component_Association (Loc,
- Choices => New_List (Make_Identifier (Loc, Chars (Arg))),
+ Choices => New_List (Make_Identifier (Nam_Loc, Nam)),
Expression => Relocate_Node (Expr)));
end if;
- -- Remove the pragma argument name as this information has been
- -- captured in the aggregate.
-
- if Nkind (Arg) = N_Pragma_Argument_Association then
- Set_Chars (Arg, No_Name);
- end if;
-
Set_Expression (Arg,
Make_Aggregate (Loc,
Component_Associations => Comps,
reply other threads:[~2015-03-02 11:07 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=20150302110741.GA11796@adacore.com \
--to=charlet@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kirtchev@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).