blob: ae24dd2979f76670c26a5c8f943f3992c20116ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
void mixed_yield() {
// FIXME: diagnose
co_yield 0;
return;
}
void mixed_await() {
// FIXME: diagnose
co_await 0;
return;
}
void only_coreturn() {
// FIXME: diagnose
co_return;
}
void mixed_coreturn(bool b) {
// FIXME: diagnose
if (b)
co_return;
else
return;
}
struct CtorDtor {
CtorDtor() {
co_yield 0; // expected-error {{'co_yield' cannot be used in a constructor}}
}
CtorDtor(int n) {
// The spec doesn't say this is ill-formed, but it must be.
co_await n; // expected-error {{'co_await' cannot be used in a constructor}}
}
~CtorDtor() {
co_return 0; // expected-error {{'co_return' cannot be used in a destructor}}
}
// FIXME: The spec says this is ill-formed.
void operator=(CtorDtor&) {
co_yield 0;
}
};
constexpr void constexpr_coroutine() {
co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
}
void varargs_coroutine(const char *, ...) {
co_await 0; // expected-error {{'co_await' cannot be used in a varargs function}}
}
|