[coroutines] Pass implicit object parameter to promise ctor (fix BUG37604)
Summary:
Complete the implementation of p0914r1.
Implicit object parameter should be passed to a promise constructor.
Fixes: https://bugs.llvm.org/show_bug.cgi?id=37604
Reviewers: modocache, rsmith, lewissbaker
Reviewed By: modocache
Subscribers: cfe-commits, EricWF
Differential Revision: https://reviews.llvm.org/D47454
llvm-svn: 333379
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
index 0d0588d..b5f6704 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -831,7 +831,7 @@
};
};
-extern "C" int f(mismatch_gro_type_tag1) {
+extern "C" int f(mismatch_gro_type_tag1) {
// expected-error@-1 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}}
co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
}
@@ -848,7 +848,7 @@
};
};
-extern "C" int f(mismatch_gro_type_tag2) {
+extern "C" int f(mismatch_gro_type_tag2) {
// expected-error@-1 {{cannot initialize return object of type 'int' with an lvalue of type 'void *'}}
co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
}
@@ -866,7 +866,7 @@
};
};
-extern "C" int f(mismatch_gro_type_tag3) {
+extern "C" int f(mismatch_gro_type_tag3) {
// expected-error@-1 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}}
co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
}
@@ -885,7 +885,7 @@
};
};
-extern "C" int f(mismatch_gro_type_tag4) {
+extern "C" int f(mismatch_gro_type_tag4) {
// expected-error@-1 {{cannot initialize return object of type 'int' with an rvalue of type 'char *'}}
co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
}
@@ -1246,7 +1246,10 @@
co_return;
}
+struct some_class;
+
struct good_promise_custom_constructor {
+ good_promise_custom_constructor(some_class&, float, int);
good_promise_custom_constructor(double, float, int);
good_promise_custom_constructor() = delete;
coro<good_promise_custom_constructor> get_return_object();
@@ -1261,9 +1264,20 @@
co_return;
}
+struct some_class {
+ coro<good_promise_custom_constructor>
+ good_coroutine_calls_custom_constructor(float, int) {
+ co_return;
+ }
+ coro<good_promise_custom_constructor>
+ static good_coroutine_calls_custom_constructor(double, float, int) {
+ co_return;
+ }
+};
+
struct bad_promise_no_matching_constructor {
bad_promise_no_matching_constructor(int, int, int);
- // expected-note@+1 {{'bad_promise_no_matching_constructor' has been explicitly marked deleted here}}
+ // expected-note@+1 2 {{'bad_promise_no_matching_constructor' has been explicitly marked deleted here}}
bad_promise_no_matching_constructor() = delete;
coro<bad_promise_no_matching_constructor> get_return_object();
suspend_always initial_suspend();
@@ -1278,6 +1292,14 @@
co_return;
}
+struct some_class2 {
+coro<bad_promise_no_matching_constructor>
+bad_coroutine_calls_with_no_matching_constructor(int, int, int) {
+ // expected-error@-1 {{call to deleted constructor}}
+ co_return;
+}
+};
+
} // namespace CoroHandleMemberFunctionTest
class awaitable_no_unused_warn {