> On 22 Aug 2024, at 21:27, Jason Merrill <ja...@redhat.com> wrote:
>
> On 8/22/24 3:43 PM, Iain Sandoe wrote:
>>> On 22 Aug 2024, at 17:47, Jason Merrill <ja...@redhat.com> wrote:
>>> On 8/22/24 12:35 PM, Iain Sandoe wrote:
>
>>>>>> +build_coroutine_frame_delete_expr (tree coro_fp, tree orig, tree
>>>>>> frame_size,
>>>>>> + tree promise_type, location_t loc)
>>>>>> +{
>
>>>>> Here it seems like you could already use build_op_delete_call for all of
>>>>> this, just by converting coro_fp to pointer-to-promise_type instead of to
>>>>> ptr_type_node?
>
>>>> I am missing something - the frame pointer is not a pointer to a promise
>>>> object
>>>> it is a pointer to the whole coroutine state?
>>>
>>> Yes, but you could lie about that; build_op_delete_call only uses the type
>>> for lookup (which we want to do in the promise type), then converts to
>>> void*.
>> hmm I’m having trouble with this, but not sure what I’m doing wrong - this
>> is what I have now:
>> ...
>> tree pptr_type = build_pointer_type (promise_type);
>> tree frame_arg = build1_loc (loc, CONVERT_EXPR, pptr_type, coro_fp);
>> …
>> del_coro_fr = build_op_delete_call (DELETE_EXPR, frame_arg, frame_size,
>> /*global_p=*/false,
>> /*placement=*/NULL,
>> /*alloc_fn=*/NULL,
>> tf_warning_or_error);
>> http://eel.is/c++draft/dcl.fct.def.coroutine#12 (sentence 2) says " If both
>> a usual deallocation function with only a pointer parameter and a usual
>> deallocation function with both a pointer parameter and a size parameter are
>> found, then the selected deallocation function shall be the one with two
>> parameters.”
>> however, if my promise provides both - the one with a single param is always
>> chosen.
>> It is not that the other overload is invalid - if I do not include the
>> single param version, the two param one is happily selected.
>> (I’m stumped at the moment)
>
> Ah, that's backwards from https://eel.is/c++draft/expr.delete#9.4 "If the
> deallocation functions belong to a class scope, the one without a parameter
> of type std::size_t is selected."
>
> This is implemented as
>
>> /* -- If the deallocation functions have class scope, the one
>> without
>> a parameter of type std::size_t is selected. */
>> bool want_size;
>> if (DECL_CLASS_SCOPE_P (fn))
>> want_size = false;
>
> I guess we need some way for build_op_delete_call to know that we want the
> other preference in this case.
Adding a defaulted param to the existing call seems to be messy since it would
interrupt the complain being last parm theme..
… I suppose we could add an overload with an additional bool specifying
priority to the two argument case?
if that seems reasonable, I can take that on - as part of this patch (or
separately).
Iain