diff options
author | Steve Baird <baird@adacore.com> | 2022-04-04 17:52:11 -0700 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-19 14:05:30 +0000 |
commit | 55a11c7e345dd06d6975fe8f4dc0e11ecbb581ff (patch) | |
tree | 1b1faa1b7ab2504a80b5417053e7b869a3b0508b /gcc/ada/exp_util.ads | |
parent | 8be71a90b15916a966553c47857e1579ca22d507 (diff) | |
download | gcc-55a11c7e345dd06d6975fe8f4dc0e11ecbb581ff.zip gcc-55a11c7e345dd06d6975fe8f4dc0e11ecbb581ff.tar.gz gcc-55a11c7e345dd06d6975fe8f4dc0e11ecbb581ff.tar.bz2 |
[Ada] Fix bug in handling of Predicate_Failure aspect
The run-time behavior of the Ada 2022 Predicate_Failure aspect was
incorrectly implemented. This could cause incorrect exception messages
at execution time in the case of a predicate check failure, as
demonstrated by ACATS test C324006. In addition, a new attribute
(Predicate_Expression) is defined in order to improve the FE/SPARK
interface.
gcc/ada/
* einfo-utils.ads, einfo-utils.adb: Delete Predicate_Function_M
function and Set_Predicate_Function_M procedure.
* einfo.ads: Delete comments for Is_Predicate_Function_M and
Predicate_Function_M functions. Add comment for new
Predicate_Expression function. Update comment describing
predicate functions.
* exp_util.ads, exp_util.adb (Make_Predicate_Call): Replace Mem
formal parameter with Static_Mem and Dynamic_Mem formals.
(Make_Predicate_Check): Delete Add_Failure_Expression and call
to it.
* exp_ch4.adb (Expand_N_In.Predicate_Check): Update
Make_Predicate_Call call to match profile change.
* gen_il-fields.ads: Delete Is_Predicate_Function_M field, add
Predicate_Expression field.
* gen_il-gen-gen_entities.adb: Delete Is_Predicate_Function_M
use, add Predicate_Expression use.
* sem_ch13.adb (Build_Predicate_Functions): Rename as singular,
not plural; we no longer build a Predicate_M function. Delete
Predicate_M references. Add new Boolean parameter for predicate
functions when needed. Restructure body of generated predicate
functions to implement required Predicate_Failure behavior and
to set new Predicate_Expression attribute. Remove special
treatment of raise expressions within predicate expressions.
* sem_util.ads (Predicate_Failure_Expression,
Predicate_Function_Needs_Membership_Parameter): New functions.
* sem_util.adb (Is_Current_Instance): Fix bugs which caused
wrong result.
(Is_Current_Instance_Reference_In_Type_Aspect): Delete
Is_Predicate_Function_M reference.
(Predicate_Failure_Expression): New function.
(Propagate_Predicate_Attributes): Delete Is_Predicate_Function_M
references.
Diffstat (limited to 'gcc/ada/exp_util.ads')
-rw-r--r-- | gcc/ada/exp_util.ads | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index f3456b3..464f66f 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -876,13 +876,19 @@ package Exp_Util is -- expression Expr. Expr is passed as an actual parameter in the call. function Make_Predicate_Call - (Typ : Entity_Id; - Expr : Node_Id; - Mem : Boolean := False) return Node_Id; + (Typ : Entity_Id; + Expr : Node_Id; + Static_Mem : Boolean := False; + Dynamic_Mem : Node_Id := Empty) return Node_Id; -- Typ is a type with Predicate_Function set. This routine builds a call to -- this function passing Expr as the argument, and returns it unanalyzed. - -- If Mem is set True, this is the special call for the membership case, - -- and the function called is the Predicate_Function_M if present. + -- If the callee takes a second parameter (as determined by + -- Sem_Util.Predicate_Function_Needs_Membership_Parameter), then the + -- actual parameter is determined by the two Mem parameters. + -- If Dynamic_Mem is nonempty, then Dynamic_Mem is the actual parameter. + -- Otherwise, the value of the Static_Mem parameter is passed in as + -- a Boolean literal. It is an error if Dynamic_Mem is nonempty but + -- the callee does not take a second parameter. function Make_Predicate_Check (Typ : Entity_Id; |