[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 18 Apr 2016 12:48:42 +0000 (14:48 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 18 Apr 2016 12:48:42 +0000 (14:48 +0200)
2016-04-18  Ed Schonberg  <schonberg@adacore.com>

* sem_prag.adb (Analyze_Pragma, case Test_Case): Improve error
message for wrong placement of aspect Test_Case.

2016-04-18  Hristian Kirtchev  <kirtchev@adacore.com>

* einfo.ads: Update the documentation of attribute Renamed_Object.
* exp_spark.adb (Expand_Potential_Renaming): Reimplemented.

2016-04-18  Gary Dismukes  <dismukes@adacore.com>

* exp_ch4.adb (Optimize_Length_Comparison): Return immediately
in the case of AAMP (same as for use of the -gnatd.P switch) to
suppress this optimization, which avoids creating a dependence
on the 64-bit arithmetic package.

From-SVN: r235144

gcc/ada/ChangeLog
gcc/ada/einfo.ads
gcc/ada/exp_ch4.adb
gcc/ada/exp_spark.adb
gcc/ada/sem_prag.adb

index b63747205b8b0127208ce4474dc3b574bb865adb..b72d52477fc1f35f3559cb1abe4712e0b2b91b3e 100644 (file)
@@ -1,3 +1,20 @@
+2016-04-18  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_prag.adb (Analyze_Pragma, case Test_Case): Improve error
+       message for wrong placement of aspect Test_Case.
+
+2016-04-18  Hristian Kirtchev  <kirtchev@adacore.com>
+
+       * einfo.ads: Update the documentation of attribute Renamed_Object.
+       * exp_spark.adb (Expand_Potential_Renaming): Reimplemented.
+
+2016-04-18  Gary Dismukes  <dismukes@adacore.com>
+
+       * exp_ch4.adb (Optimize_Length_Comparison): Return immediately
+       in the case of AAMP (same as for use of the -gnatd.P switch) to
+       suppress this optimization, which avoids creating a dependence
+       on the 64-bit arithmetic package.
+
 2016-04-18  Arnaud Charlet  <charlet@adacore.com>
 
        * exp_ch4.adb: Update comment.
index 1fb29e4d9ac857978a7ed7649bf95c46130ea3b3..76520c8d1899e9021c94d8df24b820cbe644dcb5 100644 (file)
@@ -3886,17 +3886,16 @@ package Einfo is
 --       package can see the entities in the package via the renaming.
 
 --    Renamed_Object (Node18)
---       Defined in all objects (constants, variables, components, formal
---       parameters, generic formal parameters, and loop parameters).
---       ??? Defined in discriminants?
---       Set non-Empty if the object was declared by a renaming declaration,
---       in which case it references the tree node for the name of the renamed
---       object. This is only possible for the variable and constant cases.
---       For formal parameters, this field is used in the course of inline
---       expansion, to map the formals of a subprogram into the corresponding
---       actuals. For formals of a task entry, it denotes the local renaming
---       that replaces the actual within the accept statement. The field is
---       Empty otherwise (it is always empty for loop parameters).
+--       Defined in components, constants, discriminants, formal parameters,
+--       generic formals, loop parameters, and variables. Set to non-Empty if
+--       the object was declared by a renaming declaration. For constants and
+--       variables, the attribute references the tree node for the name of the
+--       renamed object. For formal parameters, the field is used in inlining
+--       and maps the entities of all formal parameters of a subprogram to the
+--       entities of the corresponding actuals. For formals of a task entry,
+--       the attribute denotes the local renaming that replaces the actual
+--       within an accept statement. For all remaining cases (discriminants,
+--       loop parameters) the field is Empty.
 
 --    Renaming_Map (Uint9)
 --       Defined in generic subprograms, generic packages, and their
index 08b99a3f7832e7e046772c847eed3ac650f20fb7..2e7b36b54e8c0c2be09044d8b2a56df0c545dcd0 100644 (file)
@@ -12806,9 +12806,11 @@ package body Exp_Ch4 is
          return;
       end if;
 
-      --  Nothing to do if special -gnatd.P debug flag set
+      --  Nothing to do if special -gnatd.P debug flag set or target is AAMP.
+      --  For AAMP the 64-bit arithmetic package would get dragged in, which
+      --  we want to avoid, plus this optimization has limited benefit on AAMP.
 
-      if Debug_Flag_Dot_PP then
+      if Debug_Flag_Dot_PP or else AAMP_On_Target then
          return;
       end if;
 
index 0fb50402bb46d0ccda175c8b98a7d5b0c87b21e3..d1e97fc13bc4636c22fe6f6e103344381b1c7461 100644 (file)
@@ -31,6 +31,7 @@ with Exp_Util; use Exp_Util;
 with Sem_Res;  use Sem_Res;
 with Sem_Util; use Sem_Util;
 with Sinfo;    use Sinfo;
+with Tbuild;   use Tbuild;
 
 package body Exp_SPARK is
 
@@ -117,16 +118,35 @@ package body Exp_SPARK is
    -------------------------------
 
    procedure Expand_Potential_Renaming (N : Node_Id) is
-      E : constant Entity_Id := Entity (N);
-      T : constant Entity_Id := Etype (N);
+      Id     : constant Entity_Id  := Entity (N);
+      Loc    : constant Source_Ptr := Sloc (N);
+      Typ    : constant Entity_Id  := Etype (N);
+      Ren_Id : Node_Id;
 
    begin
       --  Replace a reference to a renaming with the actual renamed object
 
-      if Ekind (E) in Object_Kind and then Present (Renamed_Object (E)) then
-         Rewrite (N, New_Copy_Tree (Renamed_Object (E)));
-         Reset_Analyzed_Flags (N);
-         Analyze_And_Resolve (N, T);
+      if Ekind (Id) in Object_Kind then
+         Ren_Id := Renamed_Object (Id);
+
+         if Present (Ren_Id) then
+
+            --  The renamed object is an entity when instantiating generics
+            --  or inlining bodies. In this case the renaming is part of the
+            --  mapping "prologue" which links actuals to formals.
+
+            if Nkind (Ren_Id) in N_Entity then
+               Rewrite (N, New_Occurrence_Of (Ren_Id, Loc));
+
+            --  Otherwise the renamed object denotes a name
+
+            else
+               Rewrite (N, New_Copy_Tree (Ren_Id));
+               Reset_Analyzed_Flags (N);
+            end if;
+
+            Analyze_And_Resolve (N, Typ);
+         end if;
       end if;
    end Expand_Potential_Renaming;
 
index 8d212fe76c23d202113dffc7a796f0b67906e8c4..27a44d8cc5b5fbc8cff310f4d447ff7d27390558 100644 (file)
@@ -21739,7 +21739,8 @@ package body Sem_Prag is
             --  Otherwise the placement is illegal
 
             else
-               Pragma_Misplaced;
+               Error_Pragma
+                 ("pragma % must be specified within a package declaration");
                return;
             end if;
 
@@ -21778,7 +21779,9 @@ package body Sem_Prag is
             --  Otherwise the placement is illegal
 
             else
-               Pragma_Misplaced;
+               Error_Pragma
+                 ("pragma % must be applied to a library-level subprogram "
+                  & "declaration");
                return;
             end if;