aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-07-30 16:17:29 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-08-23 10:51:04 +0200
commitff356c0ab4cf514eaffc847df3c8717a5ee705d6 (patch)
tree3b346053ea8fcec84850e761f609dd3a8c902b8c /gcc
parentf67d108dbcd499cd6db6cb59484c400301e4ebd9 (diff)
downloadgcc-ff356c0ab4cf514eaffc847df3c8717a5ee705d6.zip
gcc-ff356c0ab4cf514eaffc847df3c8717a5ee705d6.tar.gz
gcc-ff356c0ab4cf514eaffc847df3c8717a5ee705d6.tar.bz2
ada: Cleanup validity of boolean operators
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/checks.adb16
1 files changed, 3 insertions, 13 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index d13e7bb..3650c07 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -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