public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Argument of pragma Depends has wrong source location
@ 2015-03-02 11:07 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-03-02 11:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: Hristian Kirtchev

[-- 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,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-02 11:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 11:07 [Ada] Argument of pragma Depends has wrong source location Arnaud Charlet

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).