[Ada] Implement predicate checks on qualified expressions (AI12-0100)
authorGary Dismukes <dismukes@adacore.com>
Mon, 17 Feb 2020 06:31:57 +0000 (01:31 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 8 Jun 2020 07:51:06 +0000 (03:51 -0400)
commit24eda9e701253cc482c0c70a102fcad103aa1591
tree2e150de90a88d8c8218f183259908a98fab78b9c
parent7b7f1ca1b28b650eedd1074bf723b04e99adcdaf
[Ada] Implement predicate checks on qualified expressions (AI12-0100)

2020-06-08  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

* checks.adb (Apply_Predicate_Check): Refine test for being in a
subprogram body to account for no Corresponding_Body case,
avoiding blowups arising due to other changes here.
* exp_ch4.adb (Expand_N_Qualified_Expression): Apply predicate
checks, if any, after constraint checks are applied.
* sem_eval.ads (Check_Expression_Against_Static_Predicate): Add
Check_Failure_Is_Error formal for conditionalizing warning vs.
error messages.
* sem_eval.adb (Check_Expression_Against_Static_Predicate):
Issue an error message rather than a warning when the new
Check_Failure_Is_Error formal is True. In the nonstatic or
Dynamic_Predicate case where the predicate is known to fail,
emit the check to ensure that folded cases get checks applied.
* sem_res.adb (Resolve_Qualified_Expression): Call
Check_Expression_Against_Static_Predicate, passing True for
Check_Failure_Is_Error, to ensure we reject static predicate
violations. Remove code that was conditionally calling
Apply_Predicate_Check, which is no longer needed, and that check
procedure shouldn't be called from a resolution routine in any
case. Also remove associated comment about preventing infinite
recursion and consistency with Resolve_Type_Conversion, since
that handling was already similarly removed from
Resolve_Type_Convesion at some point.
(Resolve_Type_Conversion): Add passing of True for
Check_Failure_Is_Error parameter on call to
Check_Expression_Against_Static_Predicate, to ensure that static
conversion cases that violate a predicate are rejected as
errors.
gcc/ada/checks.adb
gcc/ada/exp_ch4.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_eval.ads
gcc/ada/sem_res.adb