summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/coroutines.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-27 18:43:28 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-27 18:43:28 +0000
commitc8efda7f80946f7a11471ecf22a4528f875b56e8 (patch)
treea4f27bf3fa265778dca6a1ec81933137d455f0ba /clang/test/SemaCXX/coroutines.cpp
parent430b3e48931d242fe22f4d8a1f76c0b953319a4a (diff)
downloadbcm5719-llvm-c8efda7f80946f7a11471ecf22a4528f875b56e8.tar.gz
bcm5719-llvm-c8efda7f80946f7a11471ecf22a4528f875b56e8.zip
[coroutines] Add diagnostics for copy/move assignment operators and functions with deduced return types.
Summary: The title says it all. Additionally this patch refactors the diagnostic code into a separate function. Reviewers: GorNishanov, rsmith Subscribers: majnemer, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25292 llvm-svn: 285331
Diffstat (limited to 'clang/test/SemaCXX/coroutines.cpp')
-rw-r--r--clang/test/SemaCXX/coroutines.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
index f170201a2bc..a22383cd566 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -178,7 +178,19 @@ struct CtorDtor {
}
// FIXME: The spec says this is ill-formed.
void operator=(CtorDtor&) {
- co_yield 0;
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
+ }
+ void operator=(CtorDtor const &) {
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a copy assignment operator}}
+ }
+ void operator=(CtorDtor &&) {
+ co_await a; // expected-error {{'co_await' cannot be used in a move assignment operator}}
+ }
+ void operator=(CtorDtor const &&) {
+ co_await a; // expected-error {{'co_await' cannot be used in a move assignment operator}}
+ }
+ void operator=(int) {
+ co_await a; // OK. Not a special member
}
};
@@ -191,14 +203,19 @@ void unevaluated() {
typeid(co_yield a); // expected-error {{cannot be used in an unevaluated context}}
}
-constexpr void constexpr_coroutine() {
+constexpr auto constexpr_deduced_return_coroutine() {
co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
+ // expected-error@-1 {{'co_yield' cannot be used in a function with a deduced return type}}
}
void varargs_coroutine(const char *, ...) {
co_await a; // expected-error {{'co_await' cannot be used in a varargs function}}
}
+auto deduced_return_coroutine() {
+ co_await a; // expected-error {{'co_await' cannot be used in a function with a deduced return type}}
+}
+
struct outer {};
namespace dependent_operator_co_await_lookup {
@@ -355,6 +372,6 @@ coro<bad_promise_8> calls_set_exception() {
template<> struct std::experimental::coroutine_traits<int, int, const char**>
{ using promise_type = promise; };
-int main(int, const char**) { // expected-error {{'main' cannot be a coroutine}}
- co_await a; // expected-note {{function is a coroutine due to use of 'co_await' here}}
+int main(int, const char**) {
+ co_await a; // expected-error {{'co_await' cannot be used in the 'main' function}}
}
OpenPOWER on IntegriCloud