diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-04-26 19:34:50 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2020-04-26 20:29:51 +0100 |
commit | 29f55115583a0dab6cbac749c4f0804fd88e9536 (patch) | |
tree | 17d248078a09a9bae1f20fcfec4ba15a4899ae65 /gcc/cp | |
parent | 870923cd48e1e715120ff68425437e5b346283a1 (diff) |
coroutines: Do not assume parms are named [PR94752].
Parameters to user-defined coroutines might be unnamed.
In that case, we must synthesize a name for the coroutine
frame copy.
gcc/cp/ChangeLog:
2020-04-26 Iain Sandoe <iain@sandoe.co.uk>
PR c++/94752
* coroutines.cc (morph_fn_to_coro): Ensure that
unnamed function params have a usable and distinct
frame field name.
gcc/testsuite/ChangeLog:
2020-04-26 Iain Sandoe <iain@sandoe.co.uk>
PR c++/94752
* g++.dg/coroutines/pr94752.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/coroutines.cc | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f0c62783101..32408f7056b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2020-04-26 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/94752 + * coroutines.cc (morph_fn_to_coro): Ensure that + unnamed function params have a usable and distinct + frame field name. + 2020-04-24 Jason Merrill <jason@redhat.com> PR c++/94583 diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 4f254b7fd10..0a5a0c9b1d2 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3653,6 +3653,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) when we see uses. */ param_uses = new hash_map<tree, param_info>; + unsigned no_name_parm = 0; for (tree arg = DECL_ARGUMENTS (orig); arg != NULL; arg = DECL_CHAIN (arg)) { @@ -3693,8 +3694,14 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) parm.frame_type = actual_type; parm.this_ptr = is_this_parameter (arg); parm.trivial_dtor = TYPE_HAS_TRIVIAL_DESTRUCTOR (parm.frame_type); - tree pname = DECL_NAME (arg); - char *buf = xasprintf ("__parm.%s", IDENTIFIER_POINTER (pname)); + char *buf; + if (DECL_NAME (arg)) + { + tree pname = DECL_NAME (arg); + buf = xasprintf ("__parm.%s", IDENTIFIER_POINTER (pname)); + } + else + buf = xasprintf ("__unnamed_parm.%d", no_name_parm++); parm.field_id = coro_make_frame_entry (&field_list, buf, actual_type, DECL_SOURCE_LOCATION (arg)); free (buf); |