Richard Smith | cfd53b4 | 2015-10-22 06:13:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s |
| 2 | |
| 3 | void mixed_yield() { |
| 4 | // FIXME: diagnose |
| 5 | co_yield 0; |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | void mixed_await() { |
| 10 | // FIXME: diagnose |
| 11 | co_await 0; |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | void only_coreturn() { |
| 16 | // FIXME: diagnose |
| 17 | co_return; |
| 18 | } |
| 19 | |
| 20 | void mixed_coreturn(bool b) { |
| 21 | // FIXME: diagnose |
| 22 | if (b) |
| 23 | co_return; |
| 24 | else |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | struct 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 | |
| 45 | constexpr void constexpr_coroutine() { |
| 46 | co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}} |
| 47 | } |
| 48 | |
| 49 | void varargs_coroutine(const char *, ...) { |
| 50 | co_await 0; // expected-error {{'co_await' cannot be used in a varargs function}} |
| 51 | } |