1 // RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec 2 3 #include "Inputs/std-coroutine.h" 4 5 // expected-no-diagnostics 6 7 template <typename T> 8 struct promise; 9 10 template <typename T> 11 struct task { 12 using promise_type = promise<T>; 13 tasktask14 explicit task(promise_type& p) { throw 1; p.return_val = this; } 15 16 T value; 17 }; 18 19 template <typename T> 20 struct promise { get_return_objectpromise21 task<T> get_return_object() { return task{*this}; } 22 initial_suspendpromise23 std::suspend_never initial_suspend() const noexcept { return {}; } 24 final_suspendpromise25 std::suspend_never final_suspend() const noexcept { return {}; } 26 27 template <typename U> return_valuepromise28 void return_value(U&& val) { return_val->value = static_cast<U&&>(val); } 29 unhandled_exceptionpromise30 void unhandled_exception() { throw 1; } 31 32 task<T>* return_val; 33 }; 34 a_ShouldNotDiag(const int a,const int b)35task<int> a_ShouldNotDiag(const int a, const int b) { 36 if (b == 0) 37 throw b; 38 39 co_return a / b; 40 } 41 b_ShouldNotDiag(const int a,const int b)42task<int> b_ShouldNotDiag(const int a, const int b) noexcept { 43 if (b == 0) 44 throw b; 45 46 co_return a / b; 47 } 48 __anonf13bfbcf0102(const int a, const int b) 49const auto c_ShouldNotDiag = [](const int a, const int b) -> task<int> { 50 if (b == 0) 51 throw b; 52 53 co_return a / b; 54 }; 55 __anonf13bfbcf0202(const int a, const int b) 56const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> task<int> { 57 if (b == 0) 58 throw b; 59 60 co_return a / b; 61 }; 62