+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.
-- 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
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
-- 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
if Par /= Cunit_Entity (Main_Unit) then
Do_Unit_And_Dependents (CU, N);
end if;
+
end case;
end;
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;