-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'd403dd2c909' into merge-upstream-2024-10-24
- Loading branch information
Showing
9 changed files
with
409 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// https://gcc.gnu.org/PR112341 | ||
#include <coroutine> | ||
struct A { int j; }; | ||
struct B { | ||
bool await_ready(); | ||
bool await_suspend(std::coroutine_handle<>); | ||
A await_resume(); | ||
}; | ||
struct C { | ||
struct promise_type { | ||
std::suspend_always initial_suspend(); | ||
std::suspend_always final_suspend() noexcept; | ||
B yield_value(auto); | ||
void unhandled_exception(); | ||
C get_return_object(); | ||
void return_value(A); | ||
}; | ||
}; | ||
template<typename> | ||
C f() { | ||
// Make sure we verify types we can still. | ||
(co_await B()).i; // { dg-error "'struct A' has no member named 'i'" } | ||
(co_yield 123).i; // { dg-error "'struct A' has no member named 'i'" } | ||
co_return 123; // { dg-error "cannot convert 'int' to 'A'" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// https://gcc.gnu.org/PR112341 | ||
#include <coroutine> | ||
struct A { int j; }; | ||
struct B { | ||
bool await_ready(); | ||
bool await_suspend(std::coroutine_handle<>); | ||
A await_resume(); | ||
}; | ||
struct C { | ||
struct promise_type { | ||
std::suspend_always initial_suspend(); | ||
std::suspend_always final_suspend() noexcept; | ||
void unhandled_exception(); | ||
C get_return_object(); | ||
void return_void(); | ||
std::suspend_never yield_value(int x); | ||
}; | ||
}; | ||
|
||
// Similar to the above, but with a template yield_value and return_value. | ||
struct D { | ||
struct promise_type { | ||
std::suspend_always initial_suspend(); | ||
std::suspend_always final_suspend() noexcept; | ||
void unhandled_exception(); | ||
D get_return_object(); | ||
void return_value(auto); | ||
std::suspend_never yield_value(auto); | ||
}; | ||
}; | ||
|
||
template<typename> | ||
C f() { | ||
co_return; | ||
} | ||
|
||
template<typename> | ||
C g() | ||
{ | ||
co_yield 123; | ||
} | ||
|
||
template<typename> | ||
D f1() { | ||
co_return 123; | ||
} | ||
|
||
template<typename> | ||
D g1() | ||
{ | ||
co_yield 123; | ||
} | ||
|
||
void | ||
g() { | ||
f<int>(); | ||
f<bool>(); | ||
g<int>(); | ||
g<bool>(); | ||
|
||
f1<int>(); | ||
f1<bool>(); | ||
g1<int>(); | ||
g1<bool>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// https://gcc.gnu.org/PR112341 | ||
#include <coroutine> | ||
struct A { int j; }; | ||
struct B { | ||
bool await_ready(); | ||
bool await_suspend(std::coroutine_handle<>); | ||
A await_resume(); | ||
}; | ||
struct C { | ||
struct promise_type { | ||
std::suspend_always initial_suspend(); | ||
std::suspend_always final_suspend() noexcept; | ||
void unhandled_exception(); | ||
C get_return_object(); | ||
void return_void(); | ||
B yield_value(auto) { return {}; } | ||
}; | ||
}; | ||
C f1(auto) { (co_await B()).j; } | ||
C f2(auto) { (co_yield 0).j; } | ||
void g() { f1(0); f2(0); } |
Oops, something went wrong.