brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · e96aae4 Raw
62 lines · cpp
1// RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec2 3#include "Inputs/std-coroutine.h"4 5// expected-no-diagnostics6 7template <typename T>8struct promise;9 10template <typename T>11struct 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 19template <typename T>20struct 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 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 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 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 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