On 6/1/20 4:46 AM, Iain Sandoe wrote:
Hi
Confusingly, "get_return_object ()" can do two things:
- Firstly it can provide the return object for the ramp function (as
the name suggests).
- Secondly if the type of the ramp function is different from that
of the get_return_object call, this is used as a single parameter
to a CTOR for the ramp's return type.
In the first case we can rely on finish_return_stmt () to do the
necessary processing for copy elision.
In the second case, we should have passed a prvalue to the CTOR as
per the standard comment, but I had omitted the rvalue () call. Fixed
thus.
tested on x86_64-darwin, x86_64-linux, powerpc64-linux
OK for master?
OK for 10.2?
ok for both, but I think there's an existing nit ...
thanks
Iain
gcc/cp/ChangeLog:
PR c++/95346
* coroutines.cc (morph_fn_to_coro): Ensure that the get-
return-object is constructed correctly; When it is not the
final return value, pass it to the CTOR of the return type
as an rvalue, per the standard comment.
gcc/testsuite/ChangeLog:
PR c++/95346
* g++.dg/coroutines/pr95346.C: New test.
---
gcc/cp/coroutines.cc | 70 +++++++++++++++--------
gcc/testsuite/g++.dg/coroutines/pr95346.C | 26 +++++++++
2 files changed, 71 insertions(+), 25 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/coroutines/pr95346.C
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 7afa550037c..d1c2b437ade 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
{
- args = make_tree_vector_single (gro);
- arglist = &args;
+ vec<tree, va_gc> *args = NULL;
+ vec<tree, va_gc> **arglist = NULL;
+ if (!gro_is_void_p)
+ {
+ args = make_tree_vector_single (r);
+ arglist = &args;
+ }
+ r = build_special_member_call (NULL_TREE,
+ complete_ctor_identifier, arglist,
+ fn_return_type, LOOKUP_NORMAL,
+ tf_warning_or_error);
+ r = build_cplus_new (fn_return_type, r, tf_warning_or_error);
missing release_tree_vector (arg) call here?
--
Nathan Sidwell