[Ada] Internal clean up for N_Pragma nodes

Arnaud Charlet charlet@adacore.com
Wed Feb 6 10:05:00 GMT 2013


The specification for N_Pragma nodes requires that all pragma arguments
by represented by N_Pragma_Associatin nodes, but in several cases naked
expressions appeared. This patch corrects this irregularity, and also
cleans up the format of Make_Pragma calls throughout these files. This
was noticed during some new development, but does not as far as is known
affect any current functionality. It is only a latent bug, so no test
is needed.

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-02-06  Robert Dewar  <dewar@adacore.com>

	* exp_prag.adb, sem_ch3.adb, exp_attr.adb, sem_prag.adb, sem_ch6.adb,
	exp_intr.adb, exp_dist.adb, sem_ch13.adb: Internal clean up for
	N_Pragma nodes.

-------------- next part --------------
Index: exp_prag.adb
===================================================================
--- exp_prag.adb	(revision 195784)
+++ exp_prag.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -513,7 +513,7 @@
 
       Insert_After_And_Analyze (N,
          Make_Pragma (Loc,
-           Chars => Name_Machine_Attribute,
+           Chars                        => Name_Machine_Attribute,
            Pragma_Argument_Associations => New_List (
              Make_Pragma_Argument_Association (Iloc,
                Expression => New_Copy_Tree (Internal)),
@@ -644,44 +644,38 @@
                        (UI_To_Int (Exception_Code (Id)) / 8 * 8);
 
                      Excep_Alias :=
-                       Make_Pragma
-                         (Loc,
-                          Name_Linker_Alias,
-                          New_List
-                            (Make_Pragma_Argument_Association
-                               (Sloc => Loc,
-                                Expression =>
-                                  New_Reference_To (Excep_Internal, Loc)),
+                       Make_Pragma (Loc,
+                         Chars                        => Name_Linker_Alias,
+                         Pragma_Argument_Associations => New_List (
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression =>
+                               New_Reference_To (Excep_Internal, Loc)),
 
-                             Make_Pragma_Argument_Association
-                               (Sloc => Loc,
-                                Expression =>
-                                  Make_String_Literal
-                                    (Sloc => Loc,
-                                     Strval => End_String))));
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression =>
+                               Make_String_Literal (Loc, End_String))));
 
                      Insert_Action (N, Excep_Alias);
                      Analyze (Excep_Alias);
 
                      Export_Pragma :=
-                       Make_Pragma
-                         (Loc,
-                          Name_Export,
-                          New_List
-                            (Make_Pragma_Argument_Association (Loc,
-                               Expression => Make_Identifier (Loc, Name_C)),
+                       Make_Pragma (Loc,
+                         Chars                        => Name_Export,
+                         Pragma_Argument_Associations => New_List (
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression => Make_Identifier (Loc, Name_C)),
 
-                             Make_Pragma_Argument_Association (Loc,
-                               Expression =>
-                                 New_Reference_To (Excep_Internal, Loc)),
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression =>
+                               New_Reference_To (Excep_Internal, Loc)),
 
-                             Make_Pragma_Argument_Association (Loc,
-                               Expression =>
-                                 Make_String_Literal (Loc, Excep_Image)),
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression =>
+                               Make_String_Literal (Loc, Excep_Image)),
 
-                             Make_Pragma_Argument_Association (Loc,
-                                Expression =>
-                                  Make_String_Literal (Loc, Excep_Image))));
+                           Make_Pragma_Argument_Association (Loc,
+                             Expression =>
+                               Make_String_Literal (Loc, Excep_Image))));
 
                      Insert_Action (N, Export_Pragma);
                      Analyze (Export_Pragma);
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 195784)
+++ sem_ch3.adb	(working copy)
@@ -9060,17 +9060,16 @@
 
          Impl_Prag :=
            Make_Pragma (Loc,
-             Chars => Name_Implemented,
+             Chars                        => Name_Implemented,
              Pragma_Argument_Associations => New_List (
                Make_Pragma_Argument_Association (Loc,
-                 Expression =>
-                   New_Reference_To (Subp, Loc)),
+                 Expression => New_Reference_To (Subp, Loc)),
 
                Make_Pragma_Argument_Association (Loc,
                  Expression => Make_Identifier (Loc, Iface_Kind))));
 
          --  The pragma doesn't need to be analyzed because it is internally
-         --  build. It is safe to directly register it as a rep item since we
+         --  built. It is safe to directly register it as a rep item since we
          --  are only interested in the characters of the implementation kind.
 
          Record_Rep_Item (Subp, Impl_Prag);
Index: exp_attr.adb
===================================================================
--- exp_attr.adb	(revision 195784)
+++ exp_attr.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -2120,7 +2120,7 @@
                     Defining_Unit_Name => Ent)),
 
               Make_Pragma (Loc,
-                Chars => Name_Import,
+                Chars                        => Name_Import,
                 Pragma_Argument_Associations => New_List (
                   Make_Pragma_Argument_Association (Loc, Expression => Lang),
 
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 195787)
+++ sem_prag.adb	(working copy)
@@ -7289,8 +7289,7 @@
 
             Rewrite (N,
               Make_Pragma (Loc,
-                Chars => Name_Check_Policy,
-
+                Chars                        => Name_Check_Policy,
                 Pragma_Argument_Associations => New_List (
                   Make_Pragma_Argument_Association (Loc,
                     Expression => Make_Identifier (Loc, Name_Assertion)),
@@ -8436,11 +8435,10 @@
             Rewrite (N,
               Make_Pragma (Loc,
                 Chars                        => Name_Import,
-                Pragma_Argument_Associations =>
-                  New_List (
-                    Make_Pragma_Argument_Association (Loc,
-                      Expression => Make_Identifier (Loc, Name_CPP)),
-                    New_Copy (First (Pragma_Argument_Associations (N))))));
+                Pragma_Argument_Associations => New_List (
+                  Make_Pragma_Argument_Association (Loc,
+                    Expression => Make_Identifier (Loc, Name_CPP)),
+                  New_Copy (First (Pragma_Argument_Associations (N))))));
             Analyze (N);
          end CPP_Class;
 
@@ -13485,7 +13483,7 @@
             if In_Body then
                Rewrite (N,
                  Make_Pragma (Loc,
-                   Chars => Name_Check,
+                   Chars                        => Name_Check,
                    Pragma_Argument_Associations => New_List (
                      Make_Pragma_Argument_Association (Loc,
                        Expression => Make_Identifier (Loc, Name_Precondition)),
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 195787)
+++ sem_ch6.adb	(working copy)
@@ -11763,7 +11763,7 @@
          if not Expander_Active then
             CP :=
               Make_Pragma (Loc,
-                Chars => Name_Postcondition,
+                Chars                        => Name_Postcondition,
                 Pragma_Argument_Associations => New_List (
                   Make_Pragma_Argument_Association (Loc,
                     Chars      => Name_Check,
Index: exp_intr.adb
===================================================================
--- exp_intr.adb	(revision 195784)
+++ exp_intr.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -454,7 +454,7 @@
             New_Occurrence_Of (Standard_Character, Loc)),
 
         Make_Pragma (Loc,
-          Chars => Name_Import,
+          Chars                        => Name_Import,
           Pragma_Argument_Associations => New_List (
             Make_Pragma_Argument_Association (Loc,
               Expression => Make_Identifier (Loc, Name_Ada)),
Index: exp_dist.adb
===================================================================
--- exp_dist.adb	(revision 195784)
+++ exp_dist.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -2176,7 +2176,7 @@
 
                Append_To (Decls,
                  Make_Pragma (Loc,
-                   Chars => Name_Import,
+                   Chars                        => Name_Import,
                    Pragma_Argument_Associations => New_List (
                      Make_Pragma_Argument_Association (Loc,
                        Chars      => Name_Convention,
Index: sem_ch13.adb
===================================================================
--- sem_ch13.adb	(revision 195784)
+++ sem_ch13.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -843,7 +843,9 @@
             Prag :=
               Make_Pragma (Loc,
                 Pragma_Argument_Associations => New_List (
-                  New_Occurrence_Of (Ent, Sloc (Ident))),
+                  Make_Pragma_Argument_Association (Sloc (Ident),
+                    Expression => New_Occurrence_Of (Ent, Sloc (Ident)))),
+
                 Pragma_Identifier            =>
                   Make_Identifier (Sloc (Ident), Chars (Ident)));
 
@@ -1212,21 +1214,29 @@
                   Aitem :=
                     Make_Pragma (Loc,
                       Pragma_Argument_Associations => New_List (
-                        New_Occurrence_Of (E, Loc),
-                        Relocate_Node (Expr)),
+                        Make_Pragma_Argument_Association (Loc,
+                          Expression => New_Occurrence_Of (E, Loc)),
+
+                        Make_Pragma_Argument_Association (Sloc (Expr),
+                          Expression => Relocate_Node (Expr))),
+
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Chars (Id)));
 
                when Aspect_Synchronization =>
 
                   --  The aspect corresponds to pragma Implemented.
-                  --  Construct the pragma
+                  --  Construct the pragma.
 
                   Aitem :=
                     Make_Pragma (Loc,
                       Pragma_Argument_Associations => New_List (
-                        New_Occurrence_Of (E, Loc),
-                        Relocate_Node (Expr)),
+                        Make_Pragma_Argument_Association (Loc,
+                          Expression => New_Occurrence_Of (E, Loc)),
+
+                        Make_Pragma_Argument_Association (Sloc (Expr),
+                          Expression => Relocate_Node (Expr))),
+
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Name_Implemented));
 
@@ -1241,8 +1251,11 @@
                     Make_Pragma (Loc,
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Name_Attach_Handler),
-                      Pragma_Argument_Associations =>
-                        New_List (Ent, Relocate_Node (Expr)));
+                          Pragma_Argument_Associations => New_List (
+                            Make_Pragma_Argument_Association (Sloc (Ent),
+                              Expression => Ent),
+                            Make_Pragma_Argument_Association (Sloc (Expr),
+                              Expression => Relocate_Node (Expr))));
 
                when Aspect_Dynamic_Predicate |
                     Aspect_Predicate         |
@@ -1253,8 +1266,11 @@
 
                   Aitem :=
                     Make_Pragma (Loc,
-                      Pragma_Argument_Associations =>
-                        New_List (Ent, Relocate_Node (Expr)),
+                      Pragma_Argument_Associations => New_List (
+                         Make_Pragma_Argument_Association (Sloc (Ent),
+                           Expression => Ent),
+                         Make_Pragma_Argument_Association (Sloc (Expr),
+                           Expression => Relocate_Node (Expr))),
                       Class_Present                => Class_Present (Aspect),
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Name_Predicate));
@@ -1305,8 +1321,7 @@
                      while Present (A) loop
                         A_Name := Chars (Identifier (A));
 
-                        if A_Name = Name_Import
-                             or else
+                        if A_Name = Name_Import or else
                            A_Name = Name_Export
                         then
                            if Found then
@@ -1333,7 +1348,11 @@
                         Next (A);
                      end loop;
 
-                     Arg_List := New_List (Relocate_Node (Expr), Ent);
+                     Arg_List := New_List (
+                       Make_Pragma_Argument_Association (Sloc (Expr),
+                         Expression => Relocate_Node (Expr)),
+                       Make_Pragma_Argument_Association (Sloc (Ent),
+                         Expression => Ent));
 
                      if Present (L_Assoc) then
                         Append_To (Arg_List, L_Assoc);
@@ -1361,8 +1380,9 @@
                   if Nkind (N) = N_Subprogram_Body then
                      Aitem :=
                        Make_Pragma (Loc,
-                         Pragma_Argument_Associations =>
-                           New_List (Relocate_Node (Expr)),
+                         Pragma_Argument_Associations => New_List (
+                           Make_Pragma_Argument_Association (Sloc (Expr),
+                             Expression => Relocate_Node (Expr))),
                          Pragma_Identifier            =>
                            Make_Identifier (Sloc (Id), Chars (Id)));
                   else
@@ -1380,8 +1400,10 @@
                   Aitem :=
                     Make_Pragma (Loc,
                       Pragma_Argument_Associations => New_List (
-                        Relocate_Node (Expr),
-                        New_Occurrence_Of (E, Loc)),
+                        Make_Pragma_Argument_Association (Sloc (Expr),
+                          Expression => Relocate_Node (Expr)),
+                        Make_Pragma_Argument_Association (Loc,
+                          Expression => New_Occurrence_Of (E, Loc))),
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Chars (Id)),
                       Class_Present                => Class_Present (Aspect));
@@ -1409,8 +1431,11 @@
 
                   Aitem :=
                     Make_Pragma (Loc,
-                      Pragma_Argument_Associations =>
-                        New_List (Ent, Relocate_Node (Expr)),
+                      Pragma_Argument_Associations => New_List (
+                        Make_Pragma_Argument_Association (Sloc (Ent),
+                          Expression => Ent),
+                        Make_Pragma_Argument_Association (Sloc (Expr),
+                          Expression => Relocate_Node (Expr))),
                       Class_Present                => Class_Present (Aspect),
                       Pragma_Identifier            =>
                         Make_Identifier (Sloc (Id), Name_Invariant));
@@ -1661,6 +1686,7 @@
 
                when Aspect_Contract_Case |
                     Aspect_Test_Case     =>
+
                   declare
                      Args      : List_Id;
                      Comp_Expr : Node_Id;
@@ -1692,10 +1718,9 @@
                      while Present (Comp_Expr) loop
                         New_Expr := Relocate_Node (Comp_Expr);
                         Set_Original_Node (New_Expr, Comp_Expr);
-                        Append
-                          (Make_Pragma_Argument_Association (Sloc (Comp_Expr),
-                           Expression => New_Expr),
-                           Args);
+                        Append_To (Args,
+                          Make_Pragma_Argument_Association (Sloc (Comp_Expr),
+                            Expression => New_Expr));
                         Next (Comp_Expr);
                      end loop;
 
@@ -1713,11 +1738,10 @@
 
                         New_Expr := Relocate_Node (Expression (Comp_Assn));
                         Set_Original_Node (New_Expr, Expression (Comp_Assn));
-                        Append (Make_Pragma_Argument_Association (
-                          Sloc       => Sloc (Comp_Assn),
+                        Append_To (Args,
+                          Make_Pragma_Argument_Association (Sloc (Comp_Assn),
                           Chars      => Chars (First (Choices (Comp_Assn))),
-                          Expression => New_Expr),
-                          Args);
+                          Expression => New_Expr));
                         Next (Comp_Assn);
                      end loop;
 
@@ -1893,7 +1917,9 @@
                   if No (Expr) then
                      Aitem :=
                        Make_Pragma (Loc,
-                         Pragma_Argument_Associations => New_List (Ent),
+                         Pragma_Argument_Associations => New_List (
+                           Make_Pragma_Argument_Association (Sloc (Ent),
+                             Expression => Ent)),
                          Pragma_Identifier            =>
                            Make_Identifier (Sloc (Id), Chars (Id)));
 
@@ -1940,7 +1966,9 @@
                      if Is_True (Static_Boolean (Expr)) then
                         Aitem :=
                           Make_Pragma (Loc,
-                            Pragma_Argument_Associations => New_List (Ent),
+                            Pragma_Argument_Associations => New_List (
+                              Make_Pragma_Argument_Association (Sloc (Ent),
+                                Expression => Ent)),
                             Pragma_Identifier            =>
                               Make_Identifier (Sloc (Id), Chars (Id)));
 


More information about the Gcc-patches mailing list