[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / coroutine-uninitialized-warning-crash.cpp
blob8b471206d09fe4a35deeb70872d90bc30a4425d9
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only -Wall -Wextra -Wuninitialized -fblocks
2 #include "Inputs/std-coroutine.h"
4 using namespace std;
6 struct A {
7 bool await_ready() { return true; }
8 int await_resume() { return 42; }
9 template <typename F>
10 void await_suspend(F) {}
14 struct coro_t {
15 struct promise_type {
16 coro_t get_return_object() { return {}; }
17 suspend_never initial_suspend() { return {}; }
18 suspend_never final_suspend() noexcept { return {}; }
19 A yield_value(int) { return {}; }
20 void return_void() {}
21 static void unhandled_exception() {}
25 coro_t f(int n) {
26 if (n == 0)
27 co_return;
28 co_yield 42;
29 int x = co_await A{};
32 template <class Await>
33 coro_t g(int n) {
34 if (n == 0)
35 co_return;
36 co_yield 42;
37 int x = co_await Await{};
40 int main() {
41 f(0);
42 g<A>(0);