diff options
author | dim <dim@FreeBSD.org> | 2015-12-30 11:49:41 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-12-30 11:49:41 +0000 |
commit | 3176e97f130184ece0e1a21352c8124cc83ff24a (patch) | |
tree | 0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /test/Parser/cxx1z-coroutines.cpp | |
parent | 1e9b8d38881c3213d1e67b0c47ab9b2c00721a5c (diff) | |
download | FreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.zip FreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.tar.gz |
Vendor import of clang trunk r256633:
https://llvm.org/svn/llvm-project/cfe/trunk@256633
Diffstat (limited to 'test/Parser/cxx1z-coroutines.cpp')
-rw-r--r-- | test/Parser/cxx1z-coroutines.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/Parser/cxx1z-coroutines.cpp b/test/Parser/cxx1z-coroutines.cpp new file mode 100644 index 0000000..3e69840 --- /dev/null +++ b/test/Parser/cxx1z-coroutines.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -std=c++11 -fcoroutines %s -verify + +template<typename T, typename U> +U f(T t) { + co_await t; + co_yield t; + + 1 + co_await t; + 1 + co_yield t; // expected-error {{expected expression}} + + auto x = co_await t; + auto y = co_yield t; + + for co_await (int x : t) {} + for co_await (int x = 0; x != 10; ++x) {} // expected-error {{'co_await' modifier can only be applied to range-based for loop}} + + if (t) + co_return t; + else + co_return {t}; +} + +struct Y {}; +struct X { Y operator co_await(); }; +struct Z {}; +Y operator co_await(Z); + +void f(X x, Z z) { + x.operator co_await(); + operator co_await(z); +} + +void operator co_await(); // expected-error {{must have at least one parameter}} +void operator co_await(X, Y, Z); // expected-error {{must be a unary operator}} +void operator co_await(int); // expected-error {{parameter of class or enumeration type}} |