aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-06-14 17:01:57 +0100
committerIain Sandoe <iain@sandoe.co.uk>2020-06-14 18:44:43 +0100
commitfbd1bae3d8260b5e5bfc4d7cffe8c6e659abe235 (patch)
tree743d58e9789cfe080f4a69f2ce607a8867f5468a /gcc/cp
parentb0feef39fe53fbc46c22ac0c745f91dbf96cdd00 (diff)
downloadgcc-fbd1bae3d8260b5e5bfc4d7cffe8c6e659abe235.zip
gcc-fbd1bae3d8260b5e5bfc4d7cffe8c6e659abe235.tar.gz
gcc-fbd1bae3d8260b5e5bfc4d7cffe8c6e659abe235.tar.bz2
coroutines: Handle lambda closure pointers like 'this'.
It was agreed amongst the implementors that the correct interpretation of the standard is that lambda closure pointers should be treated in the same manner as class object pointers. gcc/cp/ChangeLog: * coroutines.cc (instantiate_coro_traits): Pass a reference to lambda closure objects to traits instantiation. (morph_fn_to_coro): Likewise for promise parameter preview and allocator lookup. (cherry picked from commit 1c140cfbfa4b465a29ef26f1fdfef04c671e3c9c)
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/coroutines.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 04be11e..2e1c3f8 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -297,15 +297,14 @@ instantiate_coro_traits (tree fndecl, location_t kw)
tree functyp = TREE_TYPE (fndecl);
tree arg = DECL_ARGUMENTS (fndecl);
- bool lambda_p = LAMBDA_FUNCTION_P (fndecl);
tree arg_node = TYPE_ARG_TYPES (functyp);
tree argtypes = make_tree_vec (list_length (arg_node)-1);
unsigned p = 0;
while (arg_node != NULL_TREE && !VOID_TYPE_P (TREE_VALUE (arg_node)))
{
- /* See PR94807, as to why we must exclude lambda here. */
- if (is_this_parameter (arg) && !lambda_p)
+ if (is_this_parameter (arg)
+ || DECL_NAME (arg) == closure_identifier)
{
/* We pass a reference to *this to the param preview. */
tree ct = TREE_TYPE (TREE_TYPE (arg));
@@ -3963,9 +3962,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
{
param_info *parm_i = param_uses->get (arg);
gcc_checking_assert (parm_i);
- if (parm_i->lambda_cobj)
- vec_safe_push (args, arg);
- else if (parm_i->this_ptr)
+ if (parm_i->this_ptr || parm_i->lambda_cobj)
{
/* We pass a reference to *this to the allocator lookup. */
tree tt = TREE_TYPE (TREE_TYPE (arg));
@@ -4169,9 +4166,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
/* Add this to the promise CTOR arguments list, accounting for
refs and special handling for method this ptr. */
- if (parm.lambda_cobj)
- vec_safe_push (promise_args, arg);
- else if (parm.this_ptr)
+ if (parm.this_ptr || parm.lambda_cobj)
{
/* We pass a reference to *this to the param preview. */
tree tt = TREE_TYPE (arg);