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

[Ada] Replace low-level calls to Ekind with high-level calls to Is_Formal

High-level wrappers are easier to read. This change came up while reading
some code related to GNATprove, but then uniformly applied to the entire
frontend. For the few remaining membership tests that could be replaced
by Is_Formal it is not obvious whether the high-level routine makes the
code better.

2018-07-31  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* exp_aggr.adb, exp_ch4.adb, exp_ch6.adb, lib-xref.adb,
	repinfo.adb, sem_ch9.adb: Minor replace Ekind membership tests
	with a wrapper routine.

From-SVN: r263093
parent e8723e74
2018-07-31 Piotr Trojanek <trojanek@adacore.com> 2018-07-31 Piotr Trojanek <trojanek@adacore.com>
* exp_aggr.adb, exp_ch4.adb, exp_ch6.adb, lib-xref.adb,
repinfo.adb, sem_ch9.adb: Minor replace Ekind membership tests
with a wrapper routine.
2018-07-31 Piotr Trojanek <trojanek@adacore.com>
* ali.adb (Known_ALI_Lines): Remove 'F' as a prefix for lines * ali.adb (Known_ALI_Lines): Remove 'F' as a prefix for lines
related to the FORMAL analysis done by GNATprove. related to the FORMAL analysis done by GNATprove.
......
...@@ -7278,7 +7278,7 @@ package body Exp_Aggr is ...@@ -7278,7 +7278,7 @@ package body Exp_Aggr is
(Nkind (Expr_Q) = N_Type_Conversion (Nkind (Expr_Q) = N_Type_Conversion
or else or else
(Is_Entity_Name (Expr_Q) (Is_Entity_Name (Expr_Q)
and then Ekind (Entity (Expr_Q)) in Formal_Kind)) and then Is_Formal (Entity (Expr_Q))))
and then Tagged_Type_Expansion and then Tagged_Type_Expansion
then then
Static_Components := False; Static_Components := False;
......
...@@ -12547,7 +12547,7 @@ package body Exp_Ch4 is ...@@ -12547,7 +12547,7 @@ package body Exp_Ch4 is
Sel_Comp := Parent (Sel_Comp); Sel_Comp := Parent (Sel_Comp);
end loop; end loop;
return Ekind (Entity (Prefix (Sel_Comp))) in Formal_Kind; return Is_Formal (Entity (Prefix (Sel_Comp)));
end Prefix_Is_Formal_Parameter; end Prefix_Is_Formal_Parameter;
-- Start of processing for Has_Inferable_Discriminants -- Start of processing for Has_Inferable_Discriminants
......
...@@ -6799,7 +6799,7 @@ package body Exp_Ch6 is ...@@ -6799,7 +6799,7 @@ package body Exp_Ch6 is
and then (Nkind_In (Exp, N_Type_Conversion, and then (Nkind_In (Exp, N_Type_Conversion,
N_Unchecked_Type_Conversion) N_Unchecked_Type_Conversion)
or else (Is_Entity_Name (Exp) or else (Is_Entity_Name (Exp)
and then Ekind (Entity (Exp)) in Formal_Kind)) and then Is_Formal (Entity (Exp))))
then then
-- When the return type is limited, perform a check that the tag of -- When the return type is limited, perform a check that the tag of
-- the result is the same as the tag of the return type. -- the result is the same as the tag of the return type.
...@@ -6877,7 +6877,7 @@ package body Exp_Ch6 is ...@@ -6877,7 +6877,7 @@ package body Exp_Ch6 is
or else Nkind_In (Exp, N_Type_Conversion, or else Nkind_In (Exp, N_Type_Conversion,
N_Unchecked_Type_Conversion) N_Unchecked_Type_Conversion)
or else (Is_Entity_Name (Exp) or else (Is_Entity_Name (Exp)
and then Ekind (Entity (Exp)) in Formal_Kind) and then Is_Formal (Entity (Exp)))
or else Scope_Depth (Enclosing_Dynamic_Scope (Etype (Exp))) > or else Scope_Depth (Enclosing_Dynamic_Scope (Etype (Exp))) >
Scope_Depth (Enclosing_Dynamic_Scope (Scope_Id))) Scope_Depth (Enclosing_Dynamic_Scope (Scope_Id)))
then then
......
...@@ -1034,7 +1034,7 @@ package body Lib.Xref is ...@@ -1034,7 +1034,7 @@ package body Lib.Xref is
-- parameters may end up being marked as not coming from source -- parameters may end up being marked as not coming from source
-- although they are. Take these into account specially. -- although they are. Take these into account specially.
elsif GNATprove_Mode and then Ekind (E) in Formal_Kind then elsif GNATprove_Mode and then Is_Formal (E) then
Ent := E; Ent := E;
-- Entity does not come from source, but is a derived subprogram and -- Entity does not come from source, but is a derived subprogram and
......
...@@ -428,7 +428,7 @@ package body Repinfo is ...@@ -428,7 +428,7 @@ package body Repinfo is
List_Entities (E, Bytes_Big_Endian, True); List_Entities (E, Bytes_Big_Endian, True);
elsif Ekind (E) in Formal_Kind and then In_Subprogram then elsif Is_Formal (E) and then In_Subprogram then
null; null;
elsif Ekind_In (E, E_Entry, elsif Ekind_In (E, E_Entry,
......
...@@ -2358,7 +2358,7 @@ package body Sem_Ch9 is ...@@ -2358,7 +2358,7 @@ package body Sem_Ch9 is
if Object_Access_Level (Target_Obj) >= Scope_Depth (Outer_Ent) if Object_Access_Level (Target_Obj) >= Scope_Depth (Outer_Ent)
and then and then
(not Is_Entity_Name (Target_Obj) (not Is_Entity_Name (Target_Obj)
or else Ekind (Entity (Target_Obj)) not in Formal_Kind or else not Is_Formal (Entity (Target_Obj))
or else Enclosing /= Scope (Entity (Target_Obj))) or else Enclosing /= Scope (Entity (Target_Obj)))
then then
Error_Msg_N Error_Msg_N
......
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