Diagnosing bad uses of 'return' in coroutines is somewhat
tricky, since the user can use the keyword before we know
that the function is a coroutine (where such returns are not
permitted). At present, we are just doing a check for any
use of 'return' and erroring on that. However, we can't then
pass the function body on, since it will contain unlowered
coroutine trees.
This avoids the issue by dropping the entire function body
under that circumstance. We could do better (for 11) but
this is intended to allow back-port of other fixes to 10.
gcc/cp/ChangeLog:
PR c++/95087
* coroutines.cc (morph_fn_to_coro): If we see an
early fatal error, drop the erroneous function body.
gcc/testsuite/ChangeLog:
PR c++/95087
* g++.dg/coroutines/co-return-syntax-08-bad-return.C:
Adjust the testcase to do the compile (rather than an
-fsyntax-only parse).
ramp return value, since the user cannot fix this - a 'return' is
not allowed in a coroutine. */
TREE_NO_WARNING (orig) = true;
+ /* Discard the body, we can't process it further. */
+ pop_stmt_list (DECL_SAVED_TREE (orig));
+ DECL_SAVED_TREE (orig) = push_stmt_list ();
return false;
}
-// { dg-additional-options "-fsyntax-only -w" }
+// { dg-additional-options "-w" }
#include "coro.h"