public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-8379] coroutines: Update tests for get-return-object errors.
@ 2020-06-28 8:59 Iain D Sandoe
0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2020-06-28 8:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4631b97793fd895103d27ea2eb56845318a9d4d6
commit r10-8379-g4631b97793fd895103d27ea2eb56845318a9d4d6
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun Jun 28 08:10:12 2020 +0100
coroutines: Update tests for get-return-object errors.
We updated the handling of the errors for cases when the
ramp return cannot be constructed from the user's provided
get-return-object method. This updates the testcases to
cover this.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/void-gro-non-class-coro.C: Moved to...
* g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C: ...here.
* g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C: New test.
(cherry picked from commit 2dbc16552204ffa28b643949eb1f26b787017b39)
Diff:
---
.../coro-bad-gro-00-class-gro-scalar-return.C | 65 ++++++++++++++++++++++
...C => coro-bad-gro-01-void-gro-non-class-coro.C} | 2 +-
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C b/gcc/testsuite/g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C
new file mode 100644
index 00000000000..bd9dec6c75f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/coro-bad-gro-00-class-gro-scalar-return.C
@@ -0,0 +1,65 @@
+// Test handling of the case where we have a class g-r-o and a non-void
+// and non-class-type ramp return.
+
+#include "coro.h"
+
+int g_promise = -1;
+
+struct Thing {
+ double x;
+ Thing () : x(0.0) {}
+ ~Thing () {}
+};
+
+template<typename R, typename HandleRef, typename ...T>
+struct std::coroutine_traits<R, HandleRef, T...> {
+ struct promise_type {
+ promise_type (HandleRef h, T ...args)
+ { h = std::coroutine_handle<promise_type>::from_promise (*this);
+ PRINT ("Created Promise");
+ g_promise = 1;
+ }
+ ~promise_type () { PRINT ("Destroyed Promise"); g_promise = 0;}
+ Thing get_return_object() { return {}; }
+
+ auto initial_suspend() {
+ return std::suspend_always{};
+ }
+ auto final_suspend() { return std::suspend_never{}; }
+
+ void return_void() {}
+ void unhandled_exception() {}
+ };
+};
+
+int
+my_coro (std::coroutine_handle<>& h)
+{
+ PRINT ("coro1: about to return");
+ co_return;
+} // { dg-error {'struct Thing' used where a 'int' was expected} }
+
+int main ()
+{
+ std::coroutine_handle<> h;
+ int t = my_coro (h);
+
+ if (h.done())
+ {
+ PRINT ("main: apparently was already done...");
+ abort ();
+ }
+
+ // initial suspend.
+ h.resume ();
+
+ // The coro should have self-destructed.
+ if (g_promise)
+ {
+ PRINT ("main: apparently we did not complete...");
+ abort ();
+ }
+
+ PRINT ("main: returning");
+ return t;
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/void-gro-non-class-coro.C b/gcc/testsuite/g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C
similarity index 99%
rename from gcc/testsuite/g++.dg/coroutines/void-gro-non-class-coro.C
rename to gcc/testsuite/g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C
index 8176c8a10af..c31fcb58b2e 100644
--- a/gcc/testsuite/g++.dg/coroutines/void-gro-non-class-coro.C
+++ b/gcc/testsuite/g++.dg/coroutines/coro-bad-gro-01-void-gro-non-class-coro.C
@@ -55,5 +55,5 @@ int main ()
}
PRINT ("main: returning");
- return 0;
+ return t;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-28 8:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 8:59 [gcc r10-8379] coroutines: Update tests for get-return-object errors Iain D Sandoe
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).