aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2018-07-16 14:11:30 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-16 14:11:30 +0000
commitbf6ff5e5f5f45d28548d12e0cb8178b4c8903d37 (patch)
tree510ec671a2cc76a7943b9affdcb6b6105dfacfa2 /gcc
parentfeb7f36cad506b667a778b78d034491cb909c8c2 (diff)
downloadgcc-bf6ff5e5f5f45d28548d12e0cb8178b4c8903d37.zip
gcc-bf6ff5e5f5f45d28548d12e0cb8178b4c8903d37.tar.gz
gcc-bf6ff5e5f5f45d28548d12e0cb8178b4c8903d37.tar.bz2
[Ada] Trivial simplifications in in Walk_Library_Items
Cleanup only; semantics unaffected. 2018-07-16 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem.adb (Walk_Library_Items): Reuse local constant. (Is_Subunit_Of_Main): Turn condition to positive and flip the IF-THEN-ELSE branches; avoid potentially ineffective assignment to the Lib variable. From-SVN: r262719
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem.adb21
2 files changed, 15 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index b7a434a..02bb422 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,12 @@
2018-07-16 Piotr Trojanek <trojanek@adacore.com>
+ * sem.adb (Walk_Library_Items): Reuse local constant.
+ (Is_Subunit_Of_Main): Turn condition to positive and flip the
+ IF-THEN-ELSE branches; avoid potentially ineffective assignment to the
+ Lib variable.
+
+2018-07-16 Piotr Trojanek <trojanek@adacore.com>
+
* sem.adb (Walk_Library_Items): Deconstruct dead code.
2018-07-16 Ed Schonberg <schonberg@adacore.com>
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index 59f2900..2f2f846 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -1778,8 +1778,7 @@ package body Sem is
-- A subprogram body must be the main unit
- pragma Assert (Acts_As_Spec (CU)
- or else CU = Cunit (Main_Unit));
+ pragma Assert (Acts_As_Spec (CU) or else CU = Main_CU);
null;
when N_Function_Instantiation
@@ -1940,9 +1939,7 @@ package body Sem is
if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body)
or else Acts_As_Spec (CU)
then
- if CU = Cunit (Main_Unit)
- and then not Do_Main
- then
+ if CU = Main_CU and then not Do_Main then
Seen (Unit_Num) := False;
else
@@ -2017,7 +2014,7 @@ package body Sem is
-- parents that are instances have been loaded already.
if Present (Body_CU)
- and then Body_CU /= Cunit (Main_Unit)
+ and then Body_CU /= Main_CU
and then Nkind (Unit (Body_CU)) /= N_Subprogram_Body
and then Nkind (Unit (Comp)) /= N_Package_Declaration
then
@@ -2152,6 +2149,7 @@ package body Sem is
if Par /= Cunit_Entity (Main_Unit) then
Do_Unit_And_Dependents (CU, N);
end if;
+
end case;
end;
@@ -2183,14 +2181,11 @@ package body Sem is
function Is_Subunit_Of_Main (U : Node_Id) return Boolean is
Lib : Node_Id;
begin
- if No (U) then
- return False;
- else
+ if Present (U) and then Nkind (Unit (U)) = N_Subunit then
Lib := Library_Unit (U);
- return Nkind (Unit (U)) = N_Subunit
- and then
- (Lib = Cunit (Main_Unit)
- or else Is_Subunit_Of_Main (Lib));
+ return Lib = Main_CU or else Is_Subunit_Of_Main (Lib);
+ else
+ return False;
end if;
end Is_Subunit_Of_Main;