| 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 |
|
| 14 |
explicit task(promise_type& p) { throw 1; p.return_val = this; } |
| 15 |
|
| 16 |
T value; |
| 17 |
}; |
| 18 |
|
| 19 |
template <typename T> |
| 20 |
struct promise { |
| 21 |
task<T> get_return_object() { return task{*this}; } |
| 22 |
|
| 23 |
std::suspend_never initial_suspend() const noexcept { return {}; } |
| 24 |
|
| 25 |
std::suspend_never final_suspend() const noexcept { return {}; } |
| 26 |
|
| 27 |
template <typename U> |
| 28 |
void return_value(U&& val) { return_val->value = static_cast<U&&>(val); } |
| 29 |
|
| 30 |
void unhandled_exception() { throw 1; } |
| 31 |
|
| 32 |
task<T>* return_val; |
| 33 |
}; |
| 34 |
|
| 35 |
task<int> a_ShouldNotDiag(const int a, const int b) { |
| 36 |
if (b == 0) |
| 37 |
throw b; |
| 38 |
|
| 39 |
co_return a / b; |
| 40 |
} |
| 41 |
|
| 42 |
task<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 |
|
| 49 |
const 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 |
|
| 56 |
const 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 |
}; |