[Ada] Incorrect determination of whether an expression is predicate-static
authorSteve Baird <baird@adacore.com>
Wed, 20 Apr 2022 21:48:11 +0000 (14:48 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 30 May 2022 08:29:03 +0000 (08:29 +0000)
commitebddfe50d8bf48458db0b658b962f62548dd671f
tree4e39c5ba33e7802d161e4ad0599e0728e7c54e78
parent567bf44932542b8f861dc7880dba3273fb5838ce
[Ada] Incorrect determination of whether an expression is predicate-static

The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.

gcc/ada/

* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
about subexpressions of enclosing expressions. Generate warnings
for predicates that are known to be always true or always false,
except in the case where the predicate is expressed as a Boolean
literal. Deal with non-predicate-static expressions that have
been transformed into predicate-static expressions.  Add missing
Is_Type_Ref call to N_Membership_Test case.
gcc/ada/sem_ch13.adb