]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Cleanup validity of boolean operators
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 30 Jul 2024 14:17:29 +0000 (16:17 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 23 Aug 2024 08:51:04 +0000 (10:51 +0200)
Move detection of always valid expressions from routine
Ensure_Valid (which inserts validity checks) to Expr_Known_Valid
(which decides their validity). In particular, this patch removes
duplicated detection of boolean operators, which were recognized
in both these routines.

Code cleanup; behavior is unaffected.

gcc/ada/

* checks.adb (Ensure_Valid): Remove detection of boolean and
short-circuit operators.
(Expr_Known_Valid): Detect short-circuit operators; detection of
boolean operators was already done in this routine.

gcc/ada/checks.adb

index d13e7bb3269cedd156999985752ff7526c55f32f..3650c070b7a097e422c49c6e1892a91a6b5673e3 100644 (file)
@@ -6816,17 +6816,6 @@ package body Checks is
          end if;
       end if;
 
-      --  If this is a boolean expression, only its elementary operands need
-      --  checking: if they are valid, a boolean or short-circuit operation
-      --  with them will be valid as well.
-
-      if Base_Type (Typ) = Standard_Boolean
-        and then
-         (Nkind (Expr) in N_Op or else Nkind (Expr) in N_Short_Circuit)
-      then
-         return;
-      end if;
-
       --  If we fall through, a validity check is required
 
       Insert_Valid_Check (Expr, Related_Id, Is_Low_Bound, Is_High_Bound);
@@ -6947,9 +6936,10 @@ package body Checks is
          return True;
 
       --  The result of a membership test is always valid, since it is true or
-      --  false, there are no other possibilities.
+      --  false, there are no other possibilities; same for short-circuit
+      --  operators.
 
-      elsif Nkind (Expr) in N_Membership_Test then
+      elsif Nkind (Expr) in N_Membership_Test | N_Short_Circuit then
          return True;
 
       --  For all other cases, we do not know the expression is valid