> On 23 Jul 2024, at 21:26, Jason Merrill <ja...@redhat.com> wrote:
> 
> On 6/17/24 8:14 AM, Iain Sandoe wrote:
>> This is a minor tidy-up, tested on x86_64-darwin,
>> OK For trunk?
>> thanks
>> Iain
>> --- 8< ---
>> At present, for pre-conditions and for post-conditions with a void
>> return, we are not emitting a return statement. This patch adds the
>> relevant return statements.
> 
> Hmm, why would we need a return statement in a void function?

we do not need it,
Iain

> 
>> gcc/cp/ChangeLog:
>>      * contracts.cc (finish_function_contracts): Add return
>>      statements to pre-condition and void post-cndition
>>      checking functions.
>> Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
>> ---
>>  gcc/cp/contracts.cc | 3 +++
>>  1 file changed, 3 insertions(+)
>> diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
>> index 634e3cf4fa9..0822624a910 100644
>> --- a/gcc/cp/contracts.cc
>> +++ b/gcc/cp/contracts.cc
>> @@ -2052,6 +2052,7 @@ finish_function_contracts (tree fndecl)
>>        DECL_PENDING_INLINE_P (pre) = false;
>>        start_preparsed_function (pre, DECL_ATTRIBUTES (pre), flags);
>>        remap_and_emit_conditions (fndecl, pre, PRECONDITION_STMT);
>> +      finish_return_stmt (NULL_TREE);
>>        tree finished_pre = finish_function (false);
>>        expand_or_defer_fn (finished_pre);
>>      }
>> @@ -2065,6 +2066,8 @@ finish_function_contracts (tree fndecl)
>>        remap_and_emit_conditions (fndecl, post, POSTCONDITION_STMT);
>>        if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (post))))
>>      finish_return_stmt (get_postcondition_result_parameter (fndecl));
>> +      else
>> +    finish_return_stmt (NULL_TREE);
>>          tree finished_post = finish_function (false);
>>        expand_or_defer_fn (finished_post);
> 

Reply via email to