aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-11-06 09:43:43 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2020-11-27 04:16:04 -0500
commit4e6b87e933bbbf3671f02210261615076b998644 (patch)
tree85bc72df25393e56702ae1bbb20ec46c9385a79b
parent586f6dd1f62c0aec857cdb6d52993a28838fc11a (diff)
downloadgcc-4e6b87e933bbbf3671f02210261615076b998644.zip
gcc-4e6b87e933bbbf3671f02210261615076b998644.tar.gz
gcc-4e6b87e933bbbf3671f02210261615076b998644.tar.bz2
[Ada] Simplify Parent_Is_Boolean with subtype memberships
gcc/ada/ * sem_res.adb (Parent_Is_Boolean): Simplify. (Resolve_Op_Not): Reduce scope of a local variable.
-rw-r--r--gcc/ada/sem_res.adb34
1 files changed, 8 insertions, 26 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index de0450e..93641c9 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -10245,8 +10245,6 @@ package body Sem_Res is
--------------------
procedure Resolve_Op_Not (N : Node_Id; Typ : Entity_Id) is
- B_Typ : Entity_Id;
-
function Parent_Is_Boolean return Boolean;
-- This function determines if the parent node is a boolean operator or
-- operation (comparison op, membership test, or short circuit form) and
@@ -10259,32 +10257,16 @@ package body Sem_Res is
function Parent_Is_Boolean return Boolean is
begin
- if Paren_Count (N) /= 0 then
- return False;
+ return Paren_Count (N) = 0
+ and then Nkind (Parent (N)) in N_Membership_Test
+ | N_Op_Boolean
+ | N_Short_Circuit
+ and then Left_Opnd (Parent (N)) = N;
+ end Parent_Is_Boolean;
- else
- case Nkind (Parent (N)) is
- when N_And_Then
- | N_In
- | N_Not_In
- | N_Op_And
- | N_Op_Eq
- | N_Op_Ge
- | N_Op_Gt
- | N_Op_Le
- | N_Op_Lt
- | N_Op_Ne
- | N_Op_Or
- | N_Op_Xor
- | N_Or_Else
- =>
- return Left_Opnd (Parent (N)) = N;
+ -- Local variables
- when others =>
- return False;
- end case;
- end if;
- end Parent_Is_Boolean;
+ B_Typ : Entity_Id;
-- Start of processing for Resolve_Op_Not