aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2018-07-16 14:11:25 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-16 14:11:25 +0000
commitfeb7f36cad506b667a778b78d034491cb909c8c2 (patch)
treefa77ff3a79db958884c625643647d578d95ad160 /gcc
parent9cd7bc5e000a2be07995aea4ff762f89c0e0661e (diff)
downloadgcc-feb7f36cad506b667a778b78d034491cb909c8c2.zip
gcc-feb7f36cad506b667a778b78d034491cb909c8c2.tar.gz
gcc-feb7f36cad506b667a778b78d034491cb909c8c2.tar.bz2
[Ada] Deconstruct always-false calls to Withed_Body in Walk_Library_Items
We previously removed the calls to Set_Withed_Body; this commit deconstructs calls to Withed_Body, which always returned False. The Set_Withed_Body/Withed_Body were helping the Walk_Library_Items routine traverse the AST of several compilation units such that declarations are visited before references. However, this never worked as it should and there is no point to keep the code more complicated than necessary. No test provided, because thie removed code was ineffective (and only used in the non-compiler backends, i.e. CodePeer and GNATprove). 2018-07-16 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem.adb (Walk_Library_Items): Deconstruct dead code. From-SVN: r262718
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog4
-rw-r--r--gcc/ada/sem.adb31
2 files changed, 6 insertions, 29 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e75fcbb..b7a434a 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,7 @@
+2018-07-16 Piotr Trojanek <trojanek@adacore.com>
+
+ * sem.adb (Walk_Library_Items): Deconstruct dead code.
+
2018-07-16 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_N_Op_Xor): Use common routine
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index ca87496..59f2900 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -36,7 +36,6 @@ with Nlists; use Nlists;
with Output; use Output;
with Restrict; use Restrict;
with Sem_Attr; use Sem_Attr;
-with Sem_Aux; use Sem_Aux;
with Sem_Ch2; use Sem_Ch2;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch4; use Sem_Ch4;
@@ -1705,7 +1704,7 @@ package body Sem is
-- The main unit and its spec may depend on bodies that contain generics
-- that are instantiated in them. Iterate through the corresponding
-- contexts before processing main (spec/body) itself, to process bodies
- -- that may be present, together with their context. The spec of main
+ -- that may be present, together with their context. The spec of main
-- is processed wherever it appears in the list of units, while the body
-- is processed as the last unit in the list.
@@ -2020,8 +2019,7 @@ package body Sem is
if Present (Body_CU)
and then Body_CU /= Cunit (Main_Unit)
and then Nkind (Unit (Body_CU)) /= N_Subprogram_Body
- and then (Nkind (Unit (Comp)) /= N_Package_Declaration
- or else Present (Withed_Body (Clause)))
+ and then Nkind (Unit (Comp)) /= N_Package_Declaration
then
Body_U := Get_Cunit_Unit_Number (Body_CU);
@@ -2335,7 +2333,6 @@ package body Sem is
Context_Item : Node_Id;
Lib_Unit : Node_Id;
- Body_CU : Node_Id;
begin
Context_Item := First (Context_Items (CU));
@@ -2346,30 +2343,6 @@ package body Sem is
then
Lib_Unit := Library_Unit (Context_Item);
Action (Lib_Unit);
-
- -- If the context item indicates that a package body is needed
- -- because of an instantiation in CU, traverse the body now, even
- -- if CU is not related to the main unit. If the generic itself
- -- appears in a package body, the context item is this body, and
- -- it already appears in the traversal order, so we only need to
- -- examine the case of a context item being a package declaration.
-
- if Present (Withed_Body (Context_Item))
- and then Nkind (Unit (Lib_Unit)) = N_Package_Declaration
- and then Present (Corresponding_Body (Unit (Lib_Unit)))
- then
- Body_CU :=
- Parent
- (Unit_Declaration_Node
- (Corresponding_Body (Unit (Lib_Unit))));
-
- -- A body may have an implicit with on its own spec, in which
- -- case we must ignore this context item to prevent looping.
-
- if Unit (CU) /= Unit (Body_CU) then
- Action (Body_CU);
- end if;
- end if;
end if;
Context_Item := Next (Context_Item);