diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-20 22:40:06 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-20 22:40:06 +0000 |
commit | 23da82c5eae5717256d96da2dc3631afc161b94d (patch) | |
tree | ffa21c152a6b731249fea319261bba8f8027e7f0 /clang/test/SemaCXX/coroutines.cpp | |
parent | 25bf4a8617804da394edc8b245fc9e4bc1f05def (diff) | |
download | bcm5719-llvm-23da82c5eae5717256d96da2dc3631afc161b94d.tar.gz bcm5719-llvm-23da82c5eae5717256d96da2dc3631afc161b94d.zip |
[coroutines] Synthesize yield_value call for co_yield.
llvm-svn: 253725
Diffstat (limited to 'clang/test/SemaCXX/coroutines.cpp')
-rw-r--r-- | clang/test/SemaCXX/coroutines.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index 6ca8d314f94..9e15217031e 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -29,6 +29,13 @@ double bad_promise_type(double) { co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits<double, double>::promise_type' (aka 'int') is not a class}} } +template<> struct std::coroutine_traits<double, int> { + struct promise_type {}; +}; +double bad_promise_type_2(int) { + co_yield 0; // expected-error {{no member named 'yield_value' in 'std::coroutine_traits<double, int>::promise_type'}} +} + struct promise; // expected-note {{forward declaration}} template<typename ...T> struct std::coroutine_traits<void, T...> { using promise_type = promise; }; @@ -37,7 +44,18 @@ void undefined_promise() { // expected-error {{variable has incomplete type 'pro co_await a; } -struct promise {}; +struct yielded_thing { int a, b, c; const char *p; }; + +struct promise { + awaitable yield_value(int); // expected-note {{candidate}} + awaitable yield_value(yielded_thing); // expected-note {{candidate}} +}; + +void yield() { + co_yield 0; + co_yield {1, 2, 3, "foo"}; // FIXME expected-error {{expected expression}} + co_yield "foo"; // expected-error {{no matching}} +} void mixed_yield() { co_yield 0; // expected-note {{use of 'co_yield'}} |