Commit bf6ff5e5 by Piotr Trojanek Committed by Pierre-Marie de Rodat

[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
parent feb7f36c
2018-07-16 Piotr Trojanek <trojanek@adacore.com> 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. * sem.adb (Walk_Library_Items): Deconstruct dead code.
2018-07-16 Ed Schonberg <schonberg@adacore.com> 2018-07-16 Ed Schonberg <schonberg@adacore.com>
......
...@@ -1778,8 +1778,7 @@ package body Sem is ...@@ -1778,8 +1778,7 @@ package body Sem is
-- A subprogram body must be the main unit -- A subprogram body must be the main unit
pragma Assert (Acts_As_Spec (CU) pragma Assert (Acts_As_Spec (CU) or else CU = Main_CU);
or else CU = Cunit (Main_Unit));
null; null;
when N_Function_Instantiation when N_Function_Instantiation
...@@ -1940,9 +1939,7 @@ package body Sem is ...@@ -1940,9 +1939,7 @@ package body Sem is
if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body) if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body)
or else Acts_As_Spec (CU) or else Acts_As_Spec (CU)
then then
if CU = Cunit (Main_Unit) if CU = Main_CU and then not Do_Main then
and then not Do_Main
then
Seen (Unit_Num) := False; Seen (Unit_Num) := False;
else else
...@@ -2017,7 +2014,7 @@ package body Sem is ...@@ -2017,7 +2014,7 @@ package body Sem is
-- parents that are instances have been loaded already. -- parents that are instances have been loaded already.
if Present (Body_CU) 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 (Body_CU)) /= N_Subprogram_Body
and then Nkind (Unit (Comp)) /= N_Package_Declaration and then Nkind (Unit (Comp)) /= N_Package_Declaration
then then
...@@ -2152,6 +2149,7 @@ package body Sem is ...@@ -2152,6 +2149,7 @@ package body Sem is
if Par /= Cunit_Entity (Main_Unit) then if Par /= Cunit_Entity (Main_Unit) then
Do_Unit_And_Dependents (CU, N); Do_Unit_And_Dependents (CU, N);
end if; end if;
end case; end case;
end; end;
...@@ -2183,14 +2181,11 @@ package body Sem is ...@@ -2183,14 +2181,11 @@ package body Sem is
function Is_Subunit_Of_Main (U : Node_Id) return Boolean is function Is_Subunit_Of_Main (U : Node_Id) return Boolean is
Lib : Node_Id; Lib : Node_Id;
begin begin
if No (U) then if Present (U) and then Nkind (Unit (U)) = N_Subunit then
return False;
else
Lib := Library_Unit (U); Lib := Library_Unit (U);
return Nkind (Unit (U)) = N_Subunit return Lib = Main_CU or else Is_Subunit_Of_Main (Lib);
and then else
(Lib = Cunit (Main_Unit) return False;
or else Is_Subunit_Of_Main (Lib));
end if; end if;
end Is_Subunit_Of_Main; end Is_Subunit_Of_Main;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment