diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-01-27 10:13:09 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2020-01-27 19:46:40 +0000 |
commit | 1f2e84238c9f079747804026b6225ec8c1d0e4b7 (patch) | |
tree | 0892a7626c0499a62189acebd5968a7e50c8b952 /gcc | |
parent | 73380abd6b2783215c7950a2ade5e3f4b271e2bc (diff) | |
download | gcc-1f2e84238c9f079747804026b6225ec8c1d0e4b7.zip gcc-1f2e84238c9f079747804026b6225ec8c1d0e4b7.tar.gz gcc-1f2e84238c9f079747804026b6225ec8c1d0e4b7.tar.bz2 |
coroutines: Ensure the ramp return object is checked (PR93443).
As the PR shows, there is a pathway through the code where the
no_warning value is not set, which corresponds to a missing check
of the ramp return when it was constructed from the 'get return
object' Fixed by ensuring that the check of the return value is
carried out for both return cases.
gcc/cp/ChangeLog:
2020-01-27 Iain Sandoe <iain@sandoe.co.uk>
PR c++/93443
* coroutines.cc (morph_fn_to_coro): Check the ramp return
value when it is constructed from the 'get return object'.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/coroutines.cc | 18 |
2 files changed, 16 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5324a6e..b1bf4a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-27 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/93443 + * coroutines.cc (morph_fn_to_coro): Check the ramp return + value when it is constructed from the 'get return object'. + 2020-01-27 Nathan Sidwell <nathan@acm.org> PR c++/91826 diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index b222c1f..e8a6a40 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3526,14 +3526,9 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) /* Switch to using 'input_location' as the loc, since we're now more logically doing things related to the end of the function. */ - /* done, we just need the return value. */ - bool no_warning; - if (same_type_p (TREE_TYPE (gro), fn_return_type)) - { - /* Already got the result. */ - r = check_return_expr (DECL_RESULT (orig), &no_warning); - } - else + + /* The ramp is done, we just need the return value. */ + if (!same_type_p (TREE_TYPE (gro), fn_return_type)) { /* construct the return value with a single GRO param. */ vec<tree, va_gc> *args = make_tree_vector_single (gro); @@ -3545,6 +3540,13 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) add_stmt (r); release_tree_vector (args); } + /* Else the GRO is the return and we already built it in place. */ + + bool no_warning; + r = check_return_expr (DECL_RESULT (orig), &no_warning); + if (error_operand_p (r) && warn_return_type) + /* Suppress -Wreturn-type for the ramp. */ + TREE_NO_WARNING (orig) = true; r = build_stmt (input_location, RETURN_EXPR, DECL_RESULT (orig)); TREE_NO_WARNING (r) |= no_warning; |