Commit d7ba4df4 by Robert Dewar Committed by Arnaud Charlet

sem_ch7.adb, [...]: Code clean up...

2009-04-09  Robert Dewar  <dewar@adacore.com>

	* sem_ch7.adb, sem_ch10.adb, sem_prag.adb, sem_ch12.adb, sem_util.adb,
	exp_ch13.adb, sem_ch6.adb, exp_disp.adb, sem_ch8.adb, sem_warn.adb,
	sem_cat.adb: Code clean up: use Is_Package_Or_Generic_Package where
	possible to replace an OR of two separate tests.

From-SVN: r145823
parent 923e6ff3
2009-04-09 Robert Dewar <dewar@adacore.com> 2009-04-09 Robert Dewar <dewar@adacore.com>
* sem_ch7.adb, sem_ch10.adb, sem_prag.adb, sem_ch12.adb, sem_util.adb,
exp_ch13.adb, sem_ch6.adb, exp_disp.adb, sem_ch8.adb, sem_warn.adb,
sem_cat.adb: Code clean up: use Is_Package_Or_Generic_Package where
possible to replace an OR of two separate tests.
2009-04-09 Robert Dewar <dewar@adacore.com>
* binderr.adb, errout.adb, errutil.adb: New circuitry for handling * binderr.adb, errout.adb, errutil.adb: New circuitry for handling
Maximum_Messages. Maximum_Messages.
...@@ -6757,8 +6757,7 @@ package body Sem_Ch8 is ...@@ -6757,8 +6757,7 @@ package body Sem_Ch8 is
Full_Vis := True; Full_Vis := True;
elsif Is_Package_Or_Generic_Package (S) elsif Is_Package_Or_Generic_Package (S)
and then (In_Private_Part (S) and then (In_Private_Part (S) or else In_Package_Body (S))
or else In_Package_Body (S))
then then
Full_Vis := True; Full_Vis := True;
......
...@@ -1269,10 +1269,9 @@ package body Sem_Prag is ...@@ -1269,10 +1269,9 @@ package body Sem_Prag is
elsif Nkind (P) = N_Handled_Sequence_Of_Statements then elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
exit; exit;
elsif Nkind (P) = N_Package_Specification then elsif Nkind_In (P, N_Package_Specification,
return; N_Block_Statement)
then
elsif Nkind (P) = N_Block_Statement then
return; return;
-- Note: the following tests seem a little peculiar, because -- Note: the following tests seem a little peculiar, because
...@@ -3540,8 +3539,8 @@ package body Sem_Prag is ...@@ -3540,8 +3539,8 @@ package body Sem_Prag is
elsif (C = Convention_Java or else C = Convention_CIL) elsif (C = Convention_Java or else C = Convention_CIL)
and then and then
(Is_Package_Or_Generic_Package (Def_Id) (Is_Package_Or_Generic_Package (Def_Id)
or else Ekind (Def_Id) = E_Exception or else Ekind (Def_Id) = E_Exception
or else Nkind (Parent (Def_Id)) = N_Component_Declaration) or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
then then
Set_Imported (Def_Id); Set_Imported (Def_Id);
Set_Is_Public (Def_Id); Set_Is_Public (Def_Id);
...@@ -6580,9 +6579,8 @@ package body Sem_Prag is ...@@ -6580,9 +6579,8 @@ package body Sem_Prag is
Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Node := Cunit (Current_Sem_Unit);
Cunit_Ent := Cunit_Entity (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
if Nkind (Unit (Cunit_Node)) = N_Package_Body if Nkind_In (Unit (Cunit_Node), N_Package_Body,
or else N_Subprogram_Body)
Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
then then
Error_Pragma ("pragma% must refer to a spec, not a body"); Error_Pragma ("pragma% must refer to a spec, not a body");
else else
...@@ -7417,9 +7415,8 @@ package body Sem_Prag is ...@@ -7417,9 +7415,8 @@ package body Sem_Prag is
begin begin
GP := Parent (Parent (N)); GP := Parent (Parent (N));
if Nkind (GP) = N_Package_Declaration if Nkind_In (GP, N_Package_Declaration,
or else N_Generic_Package_Declaration)
Nkind (GP) = N_Generic_Package_Declaration
then then
GP := Parent (GP); GP := Parent (GP);
end if; end if;
...@@ -8082,9 +8079,7 @@ package body Sem_Prag is ...@@ -8082,9 +8079,7 @@ package body Sem_Prag is
Preanalyze_Spec_Expression (Arg, RTE (RE_Interrupt_Priority)); Preanalyze_Spec_Expression (Arg, RTE (RE_Interrupt_Priority));
end if; end if;
if Nkind (P) /= N_Task_Definition if not Nkind_In (P, N_Task_Definition, N_Protected_Definition) then
and then Nkind (P) /= N_Protected_Definition
then
Pragma_Misplaced; Pragma_Misplaced;
return; return;
...@@ -9261,8 +9256,8 @@ package body Sem_Prag is ...@@ -9261,8 +9256,8 @@ package body Sem_Prag is
and then Nkind (Decl) not in N_Generic_Declaration and then Nkind (Decl) not in N_Generic_Declaration
then then
Error_Pragma Error_Pragma
("pragma% misplaced, " & ("pragma% misplaced, "
"must immediately follow a declaration"); & "must immediately follow a declaration");
else else
Set_Obsolescent (Defining_Entity (Decl)); Set_Obsolescent (Defining_Entity (Decl));
...@@ -9797,10 +9792,7 @@ package body Sem_Prag is ...@@ -9797,10 +9792,7 @@ package body Sem_Prag is
-- Task or Protected, must be of type Integer -- Task or Protected, must be of type Integer
elsif Nkind (P) = N_Protected_Definition elsif Nkind_In (P, N_Protected_Definition, N_Task_Definition) then
or else
Nkind (P) = N_Task_Definition
then
Arg := Expression (Arg1); Arg := Expression (Arg1);
-- The expression must be analyzed in the special manner -- The expression must be analyzed in the special manner
...@@ -9824,10 +9816,7 @@ package body Sem_Prag is ...@@ -9824,10 +9816,7 @@ package body Sem_Prag is
else else
Set_Has_Priority_Pragma (P, True); Set_Has_Priority_Pragma (P, True);
if Nkind (P) = N_Protected_Definition if Nkind_In (P, N_Protected_Definition, N_Task_Definition) then
or else
Nkind (P) = N_Task_Definition
then
Record_Rep_Item (Defining_Identifier (Parent (P)), N); Record_Rep_Item (Defining_Identifier (Parent (P)), N);
-- exp_ch9 should use this ??? -- exp_ch9 should use this ???
end if; end if;
...@@ -10073,10 +10062,7 @@ package body Sem_Prag is ...@@ -10073,10 +10062,7 @@ package body Sem_Prag is
X : constant Node_Id := Original_Node (Arg); X : constant Node_Id := Original_Node (Arg);
begin begin
if Nkind (X) /= N_String_Literal if not Nkind_In (X, N_String_Literal, N_Identifier) then
and then
Nkind (X) /= N_Identifier
then
Error_Pragma_Arg Error_Pragma_Arg
("inappropriate argument for pragma %", Arg); ("inappropriate argument for pragma %", Arg);
end if; end if;
...@@ -10223,6 +10209,7 @@ package body Sem_Prag is ...@@ -10223,6 +10209,7 @@ package body Sem_Prag is
if not GNAT_Mode then if not GNAT_Mode then
Error_Pragma ("pragma% only available in GNAT mode"); Error_Pragma ("pragma% only available in GNAT mode");
end if; end if;
if Nkind (N) = N_Null_Statement then if Nkind (N) = N_Null_Statement then
return; return;
end if; end if;
...@@ -10444,12 +10431,11 @@ package body Sem_Prag is ...@@ -10444,12 +10431,11 @@ package body Sem_Prag is
Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Node := Cunit (Current_Sem_Unit);
Cunit_Ent := Cunit_Entity (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration if not Nkind_In (Unit (Cunit_Node), N_Package_Declaration,
and then N_Generic_Package_Declaration)
Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
then then
Error_Pragma ( Error_Pragma
"pragma% can only apply to a package declaration"); ("pragma% can only apply to a package declaration");
end if; end if;
Set_Is_Remote_Types (Cunit_Ent); Set_Is_Remote_Types (Cunit_Ent);
...@@ -10576,12 +10562,11 @@ package body Sem_Prag is ...@@ -10576,12 +10562,11 @@ package body Sem_Prag is
Cunit_Node := Cunit (Current_Sem_Unit); Cunit_Node := Cunit (Current_Sem_Unit);
Cunit_Ent := Cunit_Entity (Current_Sem_Unit); Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration if not Nkind_In (Unit (Cunit_Node), N_Package_Declaration,
and then N_Generic_Package_Declaration)
Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
then then
Error_Pragma ( Error_Pragma
"pragma% can only apply to a package declaration"); ("pragma% can only apply to a package declaration");
end if; end if;
Set_Is_Shared_Passive (Cunit_Ent); Set_Is_Shared_Passive (Cunit_Ent);
...@@ -12154,7 +12139,7 @@ package body Sem_Prag is ...@@ -12154,7 +12139,7 @@ package body Sem_Prag is
and then and then
(Is_Generic_Instance (Result) (Is_Generic_Instance (Result)
or else Nkind (Parent (Declaration_Node (Result))) = or else Nkind (Parent (Declaration_Node (Result))) =
N_Subprogram_Renaming_Declaration) N_Subprogram_Renaming_Declaration)
and then Present (Alias (Result)) and then Present (Alias (Result))
loop loop
Result := Alias (Result); Result := Alias (Result);
......
...@@ -1301,7 +1301,7 @@ package body Sem_Warn is ...@@ -1301,7 +1301,7 @@ package body Sem_Warn is
(Ekind (E1) = E_Package (Ekind (E1) = E_Package
and then and then
not Is_Package_Or_Generic_Package not Is_Package_Or_Generic_Package
(Cunit_Entity (Current_Sem_Unit)))) (Cunit_Entity (Current_Sem_Unit))))
-- Exclude instantiations, since there is no reason why every -- Exclude instantiations, since there is no reason why every
-- entity in an instantiation should be referenced. -- entity in an instantiation should be referenced.
......
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