testsuite, coroutines : Mark final awaiters and co_await operators noexcept.
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 28 Feb 2021 01:13:50 +0000 (01:13 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Sun, 28 Feb 2021 16:28:12 +0000 (16:28 +0000)
This is part of the requirement of [dcl.fct.def.coroutine]/15.

In addition to promise final_suspend() calls, the following cases must
also be noexcept as per discussion in PR95616.

- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor

Fixed for missing cases in the testsuite as a prerequisite to fixing
PR95616.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr94879-folly-1.C: Make final suspend
expression components noexcept.
* g++.dg/coroutines/pr94883-folly-2.C: Likewise.
* g++.dg/coroutines/pr95345.C: Likewise.

gcc/testsuite/g++.dg/coroutines/pr94879-folly-1.C
gcc/testsuite/g++.dg/coroutines/pr94883-folly-2.C
gcc/testsuite/g++.dg/coroutines/pr95345.C

index e815ca7..11bcce0 100644 (file)
@@ -18,14 +18,14 @@ class i {
 namespace ac {
 template <typename> class ad {
 public:
-  bool await_ready();
-  void await_resume();
-  void await_suspend(std::coroutine_handle<>);
+  bool await_ready() noexcept;
+  void await_resume() noexcept;
+  void await_suspend(std::coroutine_handle<>) noexcept;
   i ae;
 };
 } // namespace ac
 
-template <typename ab> ac::ad<ab> operator co_await(ab);
+template <typename ab> ac::ad<ab> operator co_await(ab) noexcept;
 class j {
   class l {};
 
index c5fa659..ce06cfd 100644 (file)
@@ -16,9 +16,9 @@ int f;
 class h {
   class j {
   public:
-    bool await_ready();
-    void await_suspend(std::coroutine_handle<>);
-    void await_resume();
+    bool await_ready() noexcept;
+    void await_suspend(std::coroutine_handle<>) noexcept;
+    void await_resume() noexcept;
   };
 
 public:
index 8eae611..57b95cb 100644 (file)
@@ -9,9 +9,9 @@ using namespace std::experimental;
 struct dummy_coro
 {
   using promise_type = dummy_coro;
-  bool await_ready() { return false; }
-  void await_suspend(std::coroutine_handle<>) { }
-  void await_resume() { }
+  bool await_ready() noexcept { return false; }
+  void await_suspend(std::coroutine_handle<>) noexcept { }
+  void await_resume() noexcept { }
   dummy_coro get_return_object() { return {}; }
   dummy_coro initial_suspend() { return {}; }
   dummy_coro final_suspend() noexcept { return {}; }