[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 20 Apr 2016 09:21:59 +0000 (11:21 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 20 Apr 2016 09:21:59 +0000 (11:21 +0200)
2016-04-20  Yannick Moy  <moy@adacore.com>

* osint.adb (Relocate_Path): Fix test when Path is shorter than Prefix.
* einfo.adb (Set_Overridden_Operation): Add assertion.
* sem_util.adb (Unique_Entity): for renaming-as-body return the spec
entity.

2016-04-20  Javier Miranda  <miranda@adacore.com>

* exp_unst.adb (Append_Unique_Call): New subprogram.
(Unnest_Subprogram): Replace the unique occurrence
of Call.Append() by Append_Unique_Call() which protects us from
adding to the Calls table duplicated entries.

2016-04-20  Arnaud Charlet  <charlet@adacore.com>

* exp_attr.adb (Is_GCC_Target): Fix for C backend.
* xref_lib.ads (Dependencies_Tables): instantiate
Table package with types that guarantee its safe use.
* s-imgllu.adb, s-imgint.adb, s-imguns.adb, s-imglli.adb: Avoid nested
procedures.

From-SVN: r235248

gcc/ada/ChangeLog
gcc/ada/einfo.adb
gcc/ada/exp_attr.adb
gcc/ada/exp_unst.adb
gcc/ada/osint.adb
gcc/ada/s-imgint.adb
gcc/ada/s-imglli.adb
gcc/ada/s-imgllu.adb
gcc/ada/s-imguns.adb
gcc/ada/sem_util.adb
gcc/ada/xref_lib.ads

index b1a363a0542e2ea78d79c60c9d0b68ba4fcd7ba6..bb7253679417738eef3b340d7c22ddd19f930b90 100644 (file)
@@ -1,3 +1,25 @@
+2016-04-20  Yannick Moy  <moy@adacore.com>
+
+       * osint.adb (Relocate_Path): Fix test when Path is shorter than Prefix.
+       * einfo.adb (Set_Overridden_Operation): Add assertion.
+       * sem_util.adb (Unique_Entity): for renaming-as-body return the spec
+       entity.
+
+2016-04-20  Javier Miranda  <miranda@adacore.com>
+
+       * exp_unst.adb (Append_Unique_Call): New subprogram.
+       (Unnest_Subprogram): Replace the unique occurrence
+       of Call.Append() by Append_Unique_Call() which protects us from
+       adding to the Calls table duplicated entries.
+
+2016-04-20  Arnaud Charlet  <charlet@adacore.com>
+
+       * exp_attr.adb (Is_GCC_Target): Fix for C backend.
+       * xref_lib.ads (Dependencies_Tables): instantiate
+       Table package with types that guarantee its safe use.
+       * s-imgllu.adb, s-imgint.adb, s-imguns.adb, s-imglli.adb: Avoid nested
+       procedures.
+
 2016-04-20  Arnaud Charlet  <charlet@adacore.com>
 
        * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Valid]):
index e0a9b174d076dec0d3bb5526f335e234c7bf4748..99e52d3b2b80e2d1b26d16e80dc62bf71ec3d9ba 100644 (file)
@@ -5878,6 +5878,7 @@ package body Einfo is
 
    procedure Set_Overridden_Operation (Id : E; V : E) is
    begin
+      pragma Assert (Is_Subprogram (Id) or else Is_Generic_Subprogram (Id));
       Set_Node26 (Id, V);
    end Set_Overridden_Operation;
 
index 0b0a3951ab545b7e7953087e9c1341430c21a857..cfbba77558066baf817df5e7b9db051ff80446ea 100644 (file)
@@ -7988,7 +7988,9 @@ package body Exp_Attr is
 
       function Is_GCC_Target return Boolean is
       begin
-         return not CodePeer_Mode and then not AAMP_On_Target;
+         return not CodePeer_Mode
+           and then not AAMP_On_Target
+           and then not Generate_C_Code;
       end Is_GCC_Target;
 
    --  Start of processing for Exp_Attr
index eed26e66bc923ce969b055f79cf0b6e1f2a2624d..c0a34054eedccd9dc4680f607f3228d2ee741ab9 100644 (file)
@@ -80,6 +80,10 @@ package body Exp_Unst is
    --  that are to other subprograms nested within the outer subprogram. These
    --  are the calls that may need an additional parameter.
 
+   procedure Append_Unique_Call (Call : Call_Entry);
+   --  Append a call entry to the Calls table. A check is made to see if the
+   --  table already contains this entry and if so it has no effect.
+
    -----------
    -- Urefs --
    -----------
@@ -119,6 +123,21 @@ package body Exp_Unst is
      Table_Increment      => 200,
      Table_Name           => "Unnest_Urefs");
 
+   ------------------------
+   -- Append_Unique_Call --
+   ------------------------
+
+   procedure Append_Unique_Call (Call : Call_Entry) is
+   begin
+      for J in Calls.First .. Calls.Last loop
+         if Calls.Table (J) = Call then
+            return;
+         end if;
+      end loop;
+
+      Calls.Append (Call);
+   end Append_Unique_Call;
+
    -----------------------
    -- Unnest_Subprogram --
    -----------------------
@@ -520,7 +539,7 @@ package body Exp_Unst is
                      --  Both caller and callee must be subprograms
 
                      if Is_Subprogram (Ent) then
-                        Calls.Append ((N, Current_Subprogram, Ent));
+                        Append_Unique_Call ((N, Current_Subprogram, Ent));
                      end if;
                   end if;
                end if;
index 7567d179c29c8b9ebe1c52087f158effb617005d..22327a0707cff51b236895f85bc0f4864668e459 100644 (file)
@@ -2752,7 +2752,7 @@ package body Osint is
          end if;
       end if;
 
-      if Path (Prefix'Range) = Prefix then
+      if Path'Last >= Prefix'Last and then Path (Prefix'Range) = Prefix then
          if Std_Prefix.all /= "" then
             S := new String
               (1 .. Std_Prefix'Length + Path'Last - Prefix'Last);
index 88dc5849def24f8e6d1e44ed280b039c786ece0a..4fad4e66e75db4f962d554d7dd678a57e48fbc96 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2015, 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- --
 
 package body System.Img_Int is
 
+   procedure Set_Digits
+     (T : Integer; S : in out String; P : in out Natural);
+   --  Set digits of absolute value of T, which is zero or negative. We work
+   --  with the negative of the value so that the largest negative number is
+   --  not a special case.
+
    -------------------
    -- Image_Integer --
    -------------------
@@ -53,6 +59,23 @@ package body System.Img_Int is
       Set_Image_Integer (V, S, P);
    end Image_Integer;
 
+   ----------------
+   -- Set_Digits --
+   ----------------
+
+   procedure Set_Digits
+     (T : Integer; S : in out String; P : in out Natural) is
+   begin
+      if T <= -10 then
+         Set_Digits (T / 10, S, P);
+         P := P + 1;
+         S (P) := Character'Val (48 - (T rem 10));
+      else
+         P := P + 1;
+         S (P) := Character'Val (48 - T);
+      end if;
+   end Set_Digits;
+
    -----------------------
    -- Set_Image_Integer --
    -----------------------
@@ -60,38 +83,14 @@ package body System.Img_Int is
    procedure Set_Image_Integer
      (V : Integer;
       S : in out String;
-      P : in out Natural)
-   is
-      procedure Set_Digits (T : Integer);
-      --  Set digits of absolute value of T, which is zero or negative. We work
-      --  with the negative of the value so that the largest negative number is
-      --  not a special case.
-
-      ----------------
-      -- Set_Digits --
-      ----------------
-
-      procedure Set_Digits (T : Integer) is
-      begin
-         if T <= -10 then
-            Set_Digits (T / 10);
-            P := P + 1;
-            S (P) := Character'Val (48 - (T rem 10));
-         else
-            P := P + 1;
-            S (P) := Character'Val (48 - T);
-         end if;
-      end Set_Digits;
-
-   --  Start of processing for Set_Image_Integer
-
+      P : in out Natural) is
    begin
       if V >= 0 then
-         Set_Digits (-V);
+         Set_Digits (-V, S, P);
       else
          P := P + 1;
          S (P) := '-';
-         Set_Digits (V);
+         Set_Digits (V, S, P);
       end if;
    end Set_Image_Integer;
 
index 05154fadc9186a864b0cff08252b0f03adac22de..9e7199bf528a6e7aa1206d4843b854a89fb620b9 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2015, 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- --
 
 package body System.Img_LLI is
 
+   procedure Set_Digits
+     (T : Long_Long_Integer; S : in out String; P : in out Natural);
+   --  Set digits of absolute value of T, which is zero or negative. We work
+   --  with the negative of the value so that the largest negative number is
+   --  not a special case.
+
    -----------------------------
    -- Image_Long_Long_Integer --
    -----------------------------
@@ -53,45 +59,38 @@ package body System.Img_LLI is
       Set_Image_Long_Long_Integer (V, S, P);
    end Image_Long_Long_Integer;
 
-   ------------------------------
+   ----------------
+   -- Set_Digits --
+   ----------------
+
+   procedure Set_Digits
+     (T : Long_Long_Integer; S : in out String; P : in out Natural) is
+   begin
+      if T <= -10 then
+         Set_Digits (T / 10, S, P);
+         P := P + 1;
+         S (P) := Character'Val (48 - (T rem 10));
+      else
+         P := P + 1;
+         S (P) := Character'Val (48 - T);
+      end if;
+   end Set_Digits;
+
+   ---------------------------------
    -- Set_Image_Long_Long_Integer --
-   -----------------------------
+   --------------------------------
 
    procedure Set_Image_Long_Long_Integer
      (V : Long_Long_Integer;
       S : in out String;
-      P : in out Natural)
-   is
-      procedure Set_Digits (T : Long_Long_Integer);
-      --  Set digits of absolute value of T, which is zero or negative. We work
-      --  with the negative of the value so that the largest negative number is
-      --  not a special case.
-
-      ----------------
-      -- Set_Digits --
-      ----------------
-
-      procedure Set_Digits (T : Long_Long_Integer) is
-      begin
-         if T <= -10 then
-            Set_Digits (T / 10);
-            P := P + 1;
-            S (P) := Character'Val (48 - (T rem 10));
-         else
-            P := P + 1;
-            S (P) := Character'Val (48 - T);
-         end if;
-      end Set_Digits;
-
-   --  Start of processing for Set_Image_Long_Long_Integer
-
+      P : in out Natural) is
    begin
       if V >= 0 then
-         Set_Digits (-V);
+         Set_Digits (-V, S, P);
       else
          P := P + 1;
          S (P) := '-';
-         Set_Digits (V);
+         Set_Digits (V, S, P);
       end if;
    end Set_Image_Long_Long_Integer;
 
index d1e9dd414692915092cae101ba0183e4fbbf9ff0..95ff789d96e3b4557e75ff39d014a6fb1630a9c0 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2015, 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- --
@@ -56,32 +56,17 @@ package body System.Img_LLU is
    procedure Set_Image_Long_Long_Unsigned
      (V : Long_Long_Unsigned;
       S : in out String;
-      P : in out Natural)
-   is
-      procedure Set_Digits (T : Long_Long_Unsigned);
-      --  Set digits of absolute value of T
-
-      ----------------
-      -- Set_Digits --
-      ----------------
-
-      procedure Set_Digits (T : Long_Long_Unsigned) is
-      begin
-         if T >= 10 then
-            Set_Digits (T / 10);
-            P := P + 1;
-            S (P) := Character'Val (48 + (T rem 10));
-
-         else
-            P := P + 1;
-            S (P) := Character'Val (48 + T);
-         end if;
-      end Set_Digits;
-
-   --  Start of processing for Set_Image_Long_Long_Unsigned
-
+      P : in out Natural) is
    begin
-      Set_Digits (V);
+      if V >= 10 then
+         Set_Image_Long_Long_Unsigned (V / 10, S, P);
+         P := P + 1;
+         S (P) := Character'Val (48 + (V rem 10));
+
+      else
+         P := P + 1;
+         S (P) := Character'Val (48 + V);
+      end if;
    end Set_Image_Long_Long_Unsigned;
 
 end System.Img_LLU;
index a2cce144c3c92dd3478b3cc4487fd5bc9a80db1a..c6df94c936ac46ba7640fcb1b2d30a9d041f3425 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2015, 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- --
@@ -56,32 +56,17 @@ package body System.Img_Uns is
    procedure Set_Image_Unsigned
      (V : Unsigned;
       S : in out String;
-      P : in out Natural)
-   is
-      procedure Set_Digits (T : Unsigned);
-      --  Set decimal digits of value of T
-
-      ----------------
-      -- Set_Digits --
-      ----------------
-
-      procedure Set_Digits (T : Unsigned) is
-      begin
-         if T >= 10 then
-            Set_Digits (T / 10);
-            P := P + 1;
-            S (P) := Character'Val (48 + (T rem 10));
-
-         else
-            P := P + 1;
-            S (P) := Character'Val (48 + T);
-         end if;
-      end Set_Digits;
-
-   --  Start of processing for Set_Image_Unsigned
-
+      P : in out Natural) is
    begin
-      Set_Digits (V);
+      if V >= 10 then
+         Set_Image_Unsigned (V / 10, S, P);
+         P := P + 1;
+         S (P) := Character'Val (48 + (V rem 10));
+
+      else
+         P := P + 1;
+         S (P) := Character'Val (48 + V);
+      end if;
    end Set_Image_Unsigned;
 
 end System.Img_Uns;
index da7d00a5b65fd6a4f936d136cf7710981826b9da..d0479cf318842cb0d96318e665d178c1873ef7d7 100644 (file)
@@ -20138,6 +20138,9 @@ package body Sem_Util is
               and then Present (Corresponding_Spec_Of_Stub (P))
             then
                U := Corresponding_Spec_Of_Stub (P);
+            elsif Nkind (P) = N_Subprogram_Renaming_Declaration
+            then
+               U := Corresponding_Spec (P);
             end if;
 
          when E_Task_Body =>
index e0db3fdb7007c7ef91bb9a6b4d2d710c10825864..8d8a4ed282bce7ef07f2e1718edebe6e348a6c35 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1998-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1998-2015, 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- --
@@ -134,7 +134,7 @@ private
 
    package Dependencies_Tables is new GNAT.Dynamic_Tables
      (Table_Component_Type => Xr_Tabls.File_Reference,
-      Table_Index_Type     => Positive,
+      Table_Index_Type     => Natural,
       Table_Low_Bound      => 1,
       Table_Initial        => 400,
       Table_Increment      => 100);