blob: 68ef91c81727ebb5ce1b61d726c90583be99ecbd [file] [log] [blame]
Gor Nishanov4ffb4342016-10-02 03:31:58 +00001// RUN: %clang_cc1 -std=c++11 -fcoroutines-ts %s -verify
Richard Smith0e304ea2015-10-22 04:46:14 +00002
3template<typename T, typename U>
4U f(T t) {
5 co_await t;
6 co_yield t;
7
8 1 + co_await t;
9 1 + co_yield t; // expected-error {{expected expression}}
10
11 auto x = co_await t;
Richard Smithd7bed4d2015-11-22 02:57:17 +000012 auto y = co_yield t;
Richard Smith0e304ea2015-10-22 04:46:14 +000013
14 for co_await (int x : t) {}
15 for co_await (int x = 0; x != 10; ++x) {} // expected-error {{'co_await' modifier can only be applied to range-based for loop}}
16
17 if (t)
18 co_return t;
19 else
20 co_return {t};
21}
Richard Smith9be594e2015-10-22 05:12:22 +000022
23struct Y {};
24struct X { Y operator co_await(); };
25struct Z {};
26Y operator co_await(Z);
27
28void f(X x, Z z) {
29 x.operator co_await();
30 operator co_await(z);
31}
32
33void operator co_await(); // expected-error {{must have at least one parameter}}
34void operator co_await(X, Y, Z); // expected-error {{must be a unary operator}}
35void operator co_await(int); // expected-error {{parameter of class or enumeration type}}