* [Ada] Remove excessive defensive calls to Is_Type
@ 2020-10-15 9:40 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-10-15 9:40 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 421 bytes --]
It is excessive for Is_Type to guard a call to Is_Discrete_Type, because
both are implemented as Ekind membership test and are equally likely to
fail or succeed.
Part of a cleanup in code related to propagation of subtype predicate
flags.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch3.adb (Access_Subprogram_Declaration): Remove extra
parens.
(Make_Index): Remove excessive calls to Is_Type.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1189 bytes --]
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -1185,7 +1185,7 @@ package body Sem_Ch3 is
end;
end if;
- if not (Is_Type (Etype (Desig_Type))) then
+ if not Is_Type (Etype (Desig_Type)) then
Error_Msg_N
("expect type in function specification",
Result_Definition (T_Def));
@@ -19214,7 +19214,6 @@ package body Sem_Ch3 is
if Nkind (Low_Bound (N)) = N_Attribute_Reference
and then Attribute_Name (Low_Bound (N)) = Name_First
and then Is_Entity_Name (Prefix (Low_Bound (N)))
- and then Is_Type (Entity (Prefix (Low_Bound (N))))
and then Is_Discrete_Type (Entity (Prefix (Low_Bound (N))))
then
-- The type of the index will be the type of the prefix, as long
@@ -19266,7 +19265,6 @@ package body Sem_Ch3 is
if Is_Entity_Name (Prefix (N))
and then Comes_From_Source (N)
- and then Is_Type (Entity (Prefix (N)))
and then Is_Discrete_Type (Entity (Prefix (N)))
then
Def_Id := Entity (Prefix (N));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-15 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 9:40 [Ada] Remove excessive defensive calls to Is_Type Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).