Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / warn-throw-out-noexcept-coro.cpp
blobe96aae4fefc6b194be7e2224e079c2038bb119fd
1 // RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec
3 #include "Inputs/std-coroutine.h"
5 // expected-no-diagnostics
7 template <typename T>
8 struct promise;
10 template <typename T>
11 struct task {
12 using promise_type = promise<T>;
14 explicit task(promise_type& p) { throw 1; p.return_val = this; }
16 T value;
19 template <typename T>
20 struct promise {
21 task<T> get_return_object() { return task{*this}; }
23 std::suspend_never initial_suspend() const noexcept { return {}; }
25 std::suspend_never final_suspend() const noexcept { return {}; }
27 template <typename U>
28 void return_value(U&& val) { return_val->value = static_cast<U&&>(val); }
30 void unhandled_exception() { throw 1; }
32 task<T>* return_val;
35 task<int> a_ShouldNotDiag(const int a, const int b) {
36 if (b == 0)
37 throw b;
39 co_return a / b;
42 task<int> b_ShouldNotDiag(const int a, const int b) noexcept {
43 if (b == 0)
44 throw b;
46 co_return a / b;
49 const auto c_ShouldNotDiag = [](const int a, const int b) -> task<int> {
50 if (b == 0)
51 throw b;
53 co_return a / b;
56 const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> task<int> {
57 if (b == 0)
58 throw b;
60 co_return a / b;