From 29a56f611a6c48dc6af556a02c0494ef928274d3 Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Thu, 21 Apr 2016 08:14:08 +0000 Subject: [PATCH] frontend.adb: Update call to Unnest_Subprograms. 2016-04-21 Javier Miranda * 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 | 10 +++++++ gcc/ada/exp_ch6.adb | 56 ----------------------------------- gcc/ada/exp_ch6.ads | 5 ---- gcc/ada/exp_dbug.adb | 13 ++++++++- gcc/ada/exp_unst.adb | 69 +++++++++++++++++++++++++++++++++++++++++++- gcc/ada/exp_unst.ads | 13 ++++----- gcc/ada/frontend.adb | 4 +-- 7 files changed, 97 insertions(+), 73 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 6c2a5c969a9..917345be9a6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2016-04-21 Javier Miranda + + * 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 * frontend.adb: Remove call to initialize Exp_Ch6. diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 7a3a22f84e0..d2cded58a27 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -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; diff --git a/gcc/ada/exp_ch6.ads b/gcc/ada/exp_ch6.ads index ec859738431..5d23e47e743 100644 --- a/gcc/ada/exp_ch6.ads +++ b/gcc/ada/exp_ch6.ads @@ -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; diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb index 2c1d5180faa..1f706d6bca5 100644 --- a/gcc/ada/exp_dbug.adb +++ b/gcc/ada/exp_dbug.adb @@ -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); diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb index 12204d86c76..d5eb07d4383 100644 --- a/gcc/ada/exp_unst.adb +++ b/gcc/ada/exp_unst.adb @@ -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; diff --git a/gcc/ada/exp_unst.ads b/gcc/ada/exp_unst.ads index e6b7c5c4446..c013e25da51 100644 --- a/gcc/ada/exp_unst.ads +++ b/gcc/ada/exp_unst.ads @@ -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; diff --git a/gcc/ada/frontend.adb b/gcc/ada/frontend.adb index 1020da70779..38619035761 100644 --- a/gcc/ada/frontend.adb +++ b/gcc/ada/frontend.adb @@ -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 -- 2.30.2