public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] coroutines: Avoid functions with unlowered coroutine trees [PR95087].
@ 2020-08-22 21:46 Giuliano Belinassi
0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1362412c7ca6bcdc7a9f4b53d2e18d931e0cb4e7
commit 1362412c7ca6bcdc7a9f4b53d2e18d931e0cb4e7
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun May 31 20:30:10 2020 +0100
coroutines: Avoid functions with unlowered coroutine trees [PR95087].
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).
Diff:
---
gcc/cp/coroutines.cc | 3 +++
gcc/testsuite/g++.dg/coroutines/co-return-syntax-08-bad-return.C | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index f3cf242b4f1..0abc579e0cb 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3585,6 +3585,9 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
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;
}
diff --git a/gcc/testsuite/g++.dg/coroutines/co-return-syntax-08-bad-return.C b/gcc/testsuite/g++.dg/coroutines/co-return-syntax-08-bad-return.C
index 4bfa41cd4a9..9b537548791 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-return-syntax-08-bad-return.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-return-syntax-08-bad-return.C
@@ -1,4 +1,4 @@
-// { dg-additional-options "-fsyntax-only -w" }
+// { dg-additional-options "-w" }
#include "coro.h"
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-22 21:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:46 [gcc/devel/autopar_devel] coroutines: Avoid functions with unlowered coroutine trees [PR95087] Giuliano Belinassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).