]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
frontend.adb: Update call to Unnest_Subprograms.
authorJavier Miranda <miranda@adacore.com>
Thu, 21 Apr 2016 08:14:08 +0000 (08:14 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 21 Apr 2016 08:14:08 +0000 (10:14 +0200)
2016-04-21  Javier Miranda  <miranda@adacore.com>

* frontend.adb: Update call to Unnest_Subprograms.
* exp_ch6.ads, exp_ch6.adb, exp_unst.ads, exp_unst.adb
(Unnest_Subprograms): Moved to package exp_unst.
* exp_unst.ads (Unnest_Subprogram): Moved to the body of the
package.
* exp_dbug.adb (Qualify_Entity_Name): Enable qualification of
enumeration literals when generating C code.

From-SVN: r235303

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch6.ads
gcc/ada/exp_dbug.adb
gcc/ada/exp_unst.adb
gcc/ada/exp_unst.ads
gcc/ada/frontend.adb

index 6c2a5c969a9d0dda63e7c74836269a1c54f9bd6e..917345be9a6c65fa1fa59421f8e864985c0819a2 100644 (file)
@@ -1,3 +1,13 @@
+2016-04-21  Javier Miranda  <miranda@adacore.com>
+
+       * frontend.adb: Update call to Unnest_Subprograms.
+       * exp_ch6.ads, exp_ch6.adb, exp_unst.ads, exp_unst.adb
+       (Unnest_Subprograms): Moved to package exp_unst.
+       * exp_unst.ads (Unnest_Subprogram): Moved to the body of the
+       package.
+       * exp_dbug.adb (Qualify_Entity_Name): Enable qualification of
+       enumeration literals when generating C code.
+
 2016-04-21  Javier Miranda  <miranda@adacore.com>
 
        * frontend.adb: Remove call to initialize Exp_Ch6.
index 7a3a22f84e0c4285153df4a473656c8c44bfa9d1..d2cded58a271a637b568160bcb28a87096283ba9 100644 (file)
@@ -42,7 +42,6 @@ with Exp_Dist;  use Exp_Dist;
 with Exp_Intr;  use Exp_Intr;
 with Exp_Pakd;  use Exp_Pakd;
 with Exp_Tss;   use Exp_Tss;
-with Exp_Unst;  use Exp_Unst;
 with Exp_Util;  use Exp_Util;
 with Freeze;    use Freeze;
 with Ghost;     use Ghost;
@@ -8434,59 +8433,4 @@ package body Exp_Ch6 is
       end loop;
    end Set_Enclosing_Sec_Stack_Return;
 
-   ------------------------
-   -- Unnest_Subprograms --
-   ------------------------
-
-   procedure Unnest_Subprograms (N : Node_Id) is
-
-      function Search_Subprograms (N : Node_Id) return Traverse_Result;
-      --  Tree visitor that search for outer level procedures with nested
-      --  subprograms and invokes Unnest_Subprogram()
-
-      ------------------------
-      -- Search_Subprograms --
-      ------------------------
-
-      function Search_Subprograms (N : Node_Id) return Traverse_Result is
-      begin
-         if Nkind_In (N, N_Subprogram_Body,
-                         N_Subprogram_Body_Stub)
-         then
-            declare
-               Spec_Id : constant Entity_Id := Unique_Defining_Entity (N);
-
-            begin
-               --  We are only interested in subprograms (not generic
-               --  subprograms), that have nested subprograms.
-
-               if Is_Subprogram (Spec_Id)
-                 and then Has_Nested_Subprogram (Spec_Id)
-                 and then Is_Library_Level_Entity (Spec_Id)
-               then
-                  Unnest_Subprogram (Spec_Id, N);
-               end if;
-            end;
-         end if;
-
-         return OK;
-      end Search_Subprograms;
-
-      ---------------
-      -- Do_Search --
-      ---------------
-
-      procedure Do_Search is new Traverse_Proc (Search_Subprograms);
-      --  Subtree visitor instantiation
-
-   --  Start of processing for Unnest_Subprograms
-
-   begin
-      if not Opt.Unnest_Subprogram_Mode then
-         return;
-      end if;
-
-      Do_Search (N);
-   end Unnest_Subprograms;
-
 end Exp_Ch6;
index ec85973843166cb6c37bc460c39909d88000830c..5d23e47e74313fcbac14d0c6a62ddd78d4e8508e 100644 (file)
@@ -209,9 +209,4 @@ package Exp_Ch6 is
    --  parameter to identify the accessibility level of the function result
    --  "determined by the point of call".
 
-   procedure Unnest_Subprograms (N : Node_Id);
-   --  Called to unnest subprograms. If we are in unnest subprogram mode, this
-   --  is the call that traverses the tree N and locates all the library level
-   --  subprograms with nested subprograms to process them.
-
 end Exp_Ch6;
index 2c1d5180faac0f4e1ba92ec836592344d2720925..1f706d6bca570d514d1bb757e0d315445dadeb48 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1996-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 1996-2016, 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- --
@@ -1441,6 +1441,17 @@ package body Exp_Dbug is
          Name_Len := Full_Qualify_Len;
          Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
 
+      --  Qualification needed for enumeration literals when generating C code
+      --  (to simplify their management in the backend).
+
+      elsif Generate_C_Code
+        and then Ekind (Ent) = E_Enumeration_Literal
+        and then Scope (Ultimate_Alias (Ent)) /= Standard_Standard
+      then
+         Fully_Qualify_Name (Ent);
+         Name_Len := Full_Qualify_Len;
+         Name_Buffer (1 .. Name_Len) := Full_Qualify_Name (1 .. Name_Len);
+
       elsif Qualify_Needed (Scope (Ent)) then
          Name_Len := 0;
          Set_Entity_Name (Ent);
index 12204d86c768b904eff0ff22d1b188a57dacde1b..d5eb07d4383e4cad9f2371490061815f800fc52b 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2014-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 2014-2016, 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- --
@@ -47,6 +47,18 @@ with Uintp;    use Uintp;
 
 package body Exp_Unst is
 
+   -----------------------
+   -- Local Subprograms --
+   -----------------------
+
+   procedure Unnest_Subprogram (Subp : Entity_Id; Subp_Body : Node_Id);
+   --  Subp is a library-level subprogram which has nested subprograms, and
+   --  Subp_Body is the corresponding N_Subprogram_Body node. This procedure
+   --  declares the AREC types and objects, adds assignments to the AREC record
+   --  as required, defines the xxxPTR types for uplevel referenced objects,
+   --  adds the ARECP parameter to all nested subprograms which need it, and
+   --  modifies all uplevel references appropriately.
+
    -----------
    -- Calls --
    -----------
@@ -1704,4 +1716,59 @@ package body Exp_Unst is
       return;
    end Unnest_Subprogram;
 
+   ------------------------
+   -- Unnest_Subprograms --
+   ------------------------
+
+   procedure Unnest_Subprograms (N : Node_Id) is
+
+      function Search_Subprograms (N : Node_Id) return Traverse_Result;
+      --  Tree visitor that search for outer level procedures with nested
+      --  subprograms and invokes Unnest_Subprogram()
+
+      ------------------------
+      -- Search_Subprograms --
+      ------------------------
+
+      function Search_Subprograms (N : Node_Id) return Traverse_Result is
+      begin
+         if Nkind_In (N, N_Subprogram_Body,
+                         N_Subprogram_Body_Stub)
+         then
+            declare
+               Spec_Id : constant Entity_Id := Unique_Defining_Entity (N);
+
+            begin
+               --  We are only interested in subprograms (not generic
+               --  subprograms), that have nested subprograms.
+
+               if Is_Subprogram (Spec_Id)
+                 and then Has_Nested_Subprogram (Spec_Id)
+                 and then Is_Library_Level_Entity (Spec_Id)
+               then
+                  Unnest_Subprogram (Spec_Id, N);
+               end if;
+            end;
+         end if;
+
+         return OK;
+      end Search_Subprograms;
+
+      ---------------
+      -- Do_Search --
+      ---------------
+
+      procedure Do_Search is new Traverse_Proc (Search_Subprograms);
+      --  Subtree visitor instantiation
+
+   --  Start of processing for Unnest_Subprograms
+
+   begin
+      if not Opt.Unnest_Subprogram_Mode then
+         return;
+      end if;
+
+      Do_Search (N);
+   end Unnest_Subprograms;
+
 end Exp_Unst;
index e6b7c5c4446720788b23dcb2e999c09ce9580784..c013e25da51a52d869e79156e89d1e6c7da87f17 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 2014-2015, Free Software Foundation, Inc.         --
+--          Copyright (C) 2014-2016, 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- --
@@ -686,12 +686,9 @@ package Exp_Unst is
    function Subp_Index (Sub : Entity_Id) return SI_Type;
    --  Given the entity for a subprogram, return corresponding Subp's index
 
-   procedure Unnest_Subprogram (Subp : Entity_Id; Subp_Body : Node_Id);
-   --  Subp is a library-level subprogram which has nested subprograms, and
-   --  Subp_Body is the corresponding N_Subprogram_Body node. This procedure
-   --  declares the AREC types and objects, adds assignments to the AREC record
-   --  as required, defines the xxxPTR types for uplevel referenced objects,
-   --  adds the ARECP parameter to all nested subprograms which need it, and
-   --  modifies all uplevel references appropriately.
+   procedure Unnest_Subprograms (N : Node_Id);
+   --  Called to unnest subprograms. If we are in unnest subprogram mode, this
+   --  is the call that traverses the tree N and locates all the library level
+   --  subprograms with nested subprograms to process them.
 
 end Exp_Unst;
index 1020da7077916dcac23aa19c643e2e6b8eb847b6..386190357618c1647ff173d2cc9b33d36eeb7a87 100644 (file)
@@ -30,8 +30,8 @@ with Checks;
 with CStand;
 with Debug;    use Debug;
 with Elists;
-with Exp_Ch6;
 with Exp_Dbug;
+with Exp_Unst;
 with Fmap;
 with Fname.UF;
 with Ghost;    use Ghost;
@@ -439,7 +439,7 @@ begin
 
          --  At this stage we can unnest subprogram bodies if required
 
-         Exp_Ch6.Unnest_Subprograms (Cunit (Main_Unit));
+         Exp_Unst.Unnest_Subprograms (Cunit (Main_Unit));
 
          --  List library units if requested