diff gcc/testsuite/g++.dg/coroutines/coro-missing-ret-void.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/g++.dg/coroutines/coro-missing-ret-void.C	Thu Feb 13 11:34:05 2020 +0900
@@ -0,0 +1,34 @@
+//  { dg-additional-options "-fsyntax-only -w" }
+
+#include "coro.h"
+
+// Diagose missing return_void() in the promise type.
+
+struct MissingRetVoid {
+  coro::coroutine_handle<> handle;
+  MissingRetVoid () : handle (nullptr) {}
+  MissingRetVoid (coro::coroutine_handle<> handle) : handle (handle) {}
+  struct missing_retvoid {
+    coro::suspend_never initial_suspend() { return {}; }
+    coro::suspend_never final_suspend() { return {}; }
+    MissingRetVoid get_return_object() {
+      return MissingRetVoid (coro::coroutine_handle<missing_retvoid>::from_promise (*this));
+    }
+    void unhandled_exception() { /*std::terminate();*/ };
+  };
+};
+
+template<> struct coro::coroutine_traits<MissingRetVoid> {
+    using promise_type = MissingRetVoid::missing_retvoid;
+};
+
+MissingRetVoid
+bar ()
+{
+  co_return; // { dg-error "no member named .return_void. in" }
+}
+
+int main (int ac, char *av[]) {
+  MissingRetVoid x = bar ();
+  return 0;
+}