summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/coroutines.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
new file mode 100644
index 00000000000..ae24dd2979f
--- /dev/null
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
+
+void mixed_yield() {
+ // FIXME: diagnose
+ co_yield 0;
+ return;
+}
+
+void mixed_await() {
+ // FIXME: diagnose
+ co_await 0;
+ return;
+}
+
+void only_coreturn() {
+ // FIXME: diagnose
+ co_return;
+}
+
+void mixed_coreturn(bool b) {
+ // FIXME: diagnose
+ if (b)
+ co_return;
+ else
+ return;
+}
+
+struct CtorDtor {
+ CtorDtor() {
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a constructor}}
+ }
+ CtorDtor(int n) {
+ // The spec doesn't say this is ill-formed, but it must be.
+ co_await n; // expected-error {{'co_await' cannot be used in a constructor}}
+ }
+ ~CtorDtor() {
+ co_return 0; // expected-error {{'co_return' cannot be used in a destructor}}
+ }
+ // FIXME: The spec says this is ill-formed.
+ void operator=(CtorDtor&) {
+ co_yield 0;
+ }
+};
+
+constexpr void constexpr_coroutine() {
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
+}
+
+void varargs_coroutine(const char *, ...) {
+ co_await 0; // expected-error {{'co_await' cannot be used in a varargs function}}
+}
OpenPOWER on IntegriCloud