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