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