tree frame_type; /* The type used to represent this parm in the frame. */
tree orig_type; /* The original type of the parm (not as passed). */
bool by_ref; /* Was passed by reference. */
- bool rv_ref; /* Was an rvalue reference. */
bool pt_ref; /* Was a pointer to object. */
bool trivial_dtor; /* The frame type has a trivial DTOR. */
bool this_ptr; /* Is 'this' */
if (parm.pt_ref)
fld_idx = build1_loc (loc, CONVERT_EXPR, TREE_TYPE (arg), fld_idx);
- /* We expect an rvalue ref. here. */
- if (parm.rv_ref)
- fld_idx = convert_to_reference (DECL_ARG_TYPE (arg), fld_idx,
- CONV_STATIC, LOOKUP_NORMAL,
- NULL_TREE, tf_warning_or_error);
-
int i;
tree *puse;
FOR_EACH_VEC_ELT (*parm.body_uses, i, puse)
if (actual_type == NULL_TREE)
actual_type = error_mark_node;
parm.orig_type = actual_type;
- parm.by_ref = parm.rv_ref = parm.pt_ref = false;
- if (TREE_CODE (actual_type) == REFERENCE_TYPE
- && TYPE_REF_IS_RVALUE (DECL_ARG_TYPE (arg)))
- {
- parm.rv_ref = true;
- actual_type = TREE_TYPE (actual_type);
- parm.frame_type = actual_type;
- }
- else if (TREE_CODE (actual_type) == REFERENCE_TYPE)
+ parm.by_ref = parm.pt_ref = false;
+ if (TREE_CODE (actual_type) == REFERENCE_TYPE)
{
/* If the user passes by reference, then we will save the
pointer to the original. As noted in
referenced item ends and then the coroutine is resumed,
we have UB; well, the user asked for it. */
actual_type = build_pointer_type (TREE_TYPE (actual_type));
- parm.frame_type = actual_type;
parm.pt_ref = true;
}
else if (TYPE_REF_P (DECL_ARG_TYPE (arg)))
- {
- parm.by_ref = true;
- parm.frame_type = actual_type;
- }
- else
- parm.frame_type = actual_type;
+ parm.by_ref = true;
+
+ parm.frame_type = actual_type;
parm.this_ptr = is_this_parameter (arg);
/* See PR94807. When a lambda is in a template instantiation, the
}
else if (parm.by_ref)
vec_safe_push (promise_args, fld_idx);
- else if (parm.rv_ref)
- vec_safe_push (promise_args, rvalue (fld_idx));
else
vec_safe_push (promise_args, arg);
if (TYPE_NEEDS_CONSTRUCTING (parm.frame_type))
{
vec<tree, va_gc> *p_in;
- if (parm.by_ref
- && classtype_has_non_deleted_move_ctor (parm.frame_type)
- && !classtype_has_non_deleted_copy_ctor (parm.frame_type))
+ if (CLASS_TYPE_P (parm.frame_type)
+ && classtype_has_non_deleted_move_ctor (parm.frame_type))
+ p_in = make_tree_vector_single (move (arg));
+ else if (lvalue_p (arg))
p_in = make_tree_vector_single (rvalue (arg));
else
p_in = make_tree_vector_single (arg);
}
else
{
- if (parm.rv_ref)
- r = convert_from_reference (arg);
- else if (!same_type_p (parm.frame_type, DECL_ARG_TYPE (arg)))
+ if (!same_type_p (parm.frame_type, DECL_ARG_TYPE (arg)))
r = build1_loc (DECL_SOURCE_LOCATION (arg), CONVERT_EXPR,
parm.frame_type, arg);
else
PRINT ("my_coro 1");
sum += co_await t_ref;
PRINT ("my_coro 2");
- sum += co_await t_rv_ref;
- PRINT ("my_coro 3");
+ // This can't work for the rvalue ref, it's always dangling.
+ //sum += co_await t_rv_ref;
+ //PRINT ("my_coro 3");
co_return sum;
}
// now do the three co_awaits.
while(!x.handle.done())
x.handle.resume();
- PRINT ("main: after resuming 3 co_awaits");
+ PRINT ("main: after resuming 2 co_awaits");
/* Now we should have the co_returned value. */
int y = x.handle.promise().get_value();
- if (y != 14)
+ if (y != 10)
{
PRINTF ("main: wrong result (%d).", y);
abort ();
}
- if (regular != 3 || copy != 1 || move != 1)
+ if (regular != 3 || copy != 0 || move != 1)
{
PRINTF ("main: unexpected ctor use (R:%d, C:%d, M:%d)\n",
regular, copy, move);
PRINT ("my_coro 1");
sum += co_await t_ref;
PRINT ("my_coro 2");
- sum += co_await t_rv_ref;
- PRINT ("my_coro 3");
+ // This can't work for the rvalue ref, it's always dangling.
+ //sum += co_await t_rv_ref;
+ //PRINT ("my_coro 3");
co_return sum;
}
// now do the three co_awaits.
while(!x.handle.done())
x.handle.resume();
- PRINT ("main: after resuming 3 co_awaits");
+ PRINT ("main: after resuming 2 co_awaits");
/* Now we should have the co_returned value. */
int y = x.handle.promise().get_value();
- if (y != 14)
+ if (y != 10)
{
PRINTF ("main: wrong result (%d).", y);
abort ();
}
- if (regular != 3 || copy != 1 || move != 1)
+ if (regular != 3 || copy != 0 || move != 1)
{
PRINTF ("main: unexpected ctor use (R:%d, C:%d, M:%d)\n",
regular, copy, move);