@@ -3065,17 +3065,17 @@ maybe_apply_function_contracts (tree fndecl)
3065
3065
/* The DECL_SAVED_TREE stmt list will be popped by our caller. */
3066
3066
}
3067
3067
3068
- /* Replace any contract attributes on SOURCE with a copy where any
3069
- references to SOURCE's PARM_DECLs have been rewritten to the corresponding
3070
- PARM_DECL in DEST. If remap_result is true, result identifier is
3071
- also re-mapped. C++20 version used this function to remap contracts on
3072
- virtual functions from base class to derived class. In such a case
3073
- postcondition identified wasn't remapped. Caller side wrapper functions
3074
- need to remap the result identifier.
3075
- I remap_post is false, postconditions are dropped from the destination. */
3068
+ /* Returns a copy of SOURCE contracts where any references to SOURCE's
3069
+ PARM_DECLs have been rewritten to the corresponding PARM_DECL in DEST. If
3070
+ remap_result is true, result identifier is also re-mapped.
3071
+ C++20 version used this function to remap contracts on virtual functions
3072
+ from base class to derived class. In such a case postcondition identifier
3073
+ wasn't remapped. Caller side wrapper functions need to remap the result
3074
+ identifier.
3075
+ If remap_post is false, postconditions are dropped from the destination. */
3076
3076
3077
- void
3078
- copy_and_remap_contracts (tree dest, tree source, bool remap_result = true ,
3077
+ tree
3078
+ remap_contracts (tree dest, tree source, bool remap_result = true ,
3079
3079
bool remap_post = true )
3080
3080
{
3081
3081
tree last = NULL_TREE, contract_attrs = NULL_TREE;
@@ -3111,7 +3111,7 @@ copy_and_remap_contracts (tree dest, tree source, bool remap_result = true,
3111
3111
contract_attrs = c;
3112
3112
}
3113
3113
3114
- set_decl_contracts (dest, contract_attrs) ;
3114
+ return contract_attrs;
3115
3115
}
3116
3116
3117
3117
/* Finish up the pre & post function definitions for a guarded FNDECL,
@@ -3407,7 +3407,10 @@ should_contract_wrap_call (bool do_pre, bool do_post, bool is_virt)
3407
3407
3408
3408
/* We always wrap virtual function calls, and non-virtual calls when
3409
3409
client-side checking is enabled for all contracts. */
3410
- if (is_virt || (flag_contract_nonattr_client_check > 1 ))
3410
+ if ((is_virt
3411
+ && (flag_contract_nonattr_inheritance_mode
3412
+ == CONTRACT_INHERITANCE_P2900R13))
3413
+ || (flag_contract_nonattr_client_check > 1 ))
3411
3414
return true ;
3412
3415
3413
3416
/* Otherwise, any function with pre-conditions when selected. */
@@ -3482,11 +3485,16 @@ define_contract_wrapper_func (const tree& fndecl, const tree& wrapdecl, void*)
3482
3485
/* We check postconditions on virtual function calls or if postcondition
3483
3486
checks are enabled for all clients. We should not get here unless there
3484
3487
are some checks to make. */
3485
- bool check_post = (flag_contract_nonattr_client_check > 1 ) || is_virtual;
3488
+ bool check_post
3489
+ = (flag_contract_nonattr_client_check > 1 )
3490
+ || (is_virtual
3491
+ && (flag_contract_nonattr_inheritance_mode
3492
+ == CONTRACT_INHERITANCE_P2900R13));
3486
3493
/* For wrappers on CDTORs we need to refer to the original contracts,
3487
3494
when the wrapper is around a clone. */
3488
- copy_and_remap_contracts (wrapdecl, DECL_ORIGIN (fndecl),
3489
- /* remap_result*/ true , check_post);
3495
+ set_decl_contracts ( wrapdecl,
3496
+ remap_contracts (wrapdecl, DECL_ORIGIN (fndecl),
3497
+ /* remap_result*/ true , check_post));
3490
3498
3491
3499
start_preparsed_function (wrapdecl, /* DECL_ATTRIBUTES*/ NULL_TREE,
3492
3500
SF_DEFAULT | SF_PRE_PARSED);
0 commit comments