===================================================================
@@ -6015,10 +6015,20 @@
-- have a test in the generic that makes sense with some types
-- and not with other types.
- and then not In_Instance
+ -- Similarly, do not rewrite membership as a validity check if
+ -- within the predicate function for the type.
+
then
- Substitute_Valid_Check;
- goto Leave;
+ if In_Instance
+ or else (Ekind (Current_Scope) = E_Function
+ and then Is_Predicate_Function (Current_Scope))
+ then
+ null;
+
+ else
+ Substitute_Valid_Check;
+ goto Leave;
+ end if;
end if;
-- If we have an explicit range, do a bit of optimization based on
===================================================================
@@ -645,8 +645,8 @@
-- case of a name which can be extended in the normal manner.
-- This case is handled by LP_State_Name or LP_State_Expr.
- -- (Ada2020) : the expression can be a reduction_expression_
- -- psarameter, i.e. a box or < Simple_Expression >
+ -- (Ada 2020): the expression can be a reduction_expression_
+ -- parameter, i.e. a box or < Simple_Expression >.
-- Note: if and case expressions (without an extra level of
-- parentheses) are permitted in this context).
@@ -679,7 +679,7 @@
end if;
-- Here we have an expression after all, which may be a reduction
- -- expression with a binary operator
+ -- expression with a binary operator.
if Token = Tok_Less then
Scan; -- past <
@@ -2894,7 +2894,7 @@
Node1 := P_Name;
return Node1;
- -- Ada2020: reduction expression parameter
+ -- Ada 2020: reduction expression parameter
when Tok_Less =>
Scan; -- past <
===================================================================
@@ -11919,6 +11919,12 @@
then
return True;
+ elsif Is_Entity_Name (Expr)
+ and then Entity (Expr) = Standard_True
+ then
+ Error_Msg_N ("predicate is redundant (always True)?", Expr);
+ return True;
+
-- That's an exhaustive list of tests, all other cases are not
-- predicate-static, so we return False.
===================================================================
@@ -4155,7 +4155,7 @@
and then Parent (Loop_Par) /= N
then
-- The parser cannot distinguish between a loop specification
- -- and an iterator specification. If after pre-analysis the
+ -- and an iterator specification. If after preanalysis the
-- proper form has been recognized, rewrite the expression to
-- reflect the right kind. This is needed for proper ASIS
-- navigation. If expansion is enabled, the transformation is
@@ -4378,7 +4378,7 @@
and then Parent (Loop_Par) /= N
then
-- The parser cannot distinguish between a loop specification
- -- and an iterator specification. If after pre-analysis the
+ -- and an iterator specification. If after preanalysis the
-- proper form has been recognized, rewrite the expression to
-- reflect the right kind. This is needed for proper ASIS
-- navigation. If expansion is enabled, the transformation is