#include /* Make sure that we correctly warn for unused co_await results. */ struct task { struct promise_type { std::suspend_never initial_suspend () noexcept; std::suspend_never final_suspend () noexcept; void return_void (); void unhandled_exception (); task get_return_object (); }; }; template struct nodiscardable : std::suspend_never { [[nodiscard]] T await_resume (); }; template struct discardable : std::suspend_never { T await_resume (); }; task thing () { co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ (void) co_await nodiscardable{}; (void) co_await nodiscardable{}; co_await discardable{}; co_await discardable{}; /* { dg-warning "implicit dereference will not access" "" { target *-*-* } {.-1} } */ } template task other_thing () { co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ (void) co_await nodiscardable{}; (void) co_await nodiscardable{}; co_await discardable{}; co_await discardable{}; /* { dg-warning "implicit dereference will not access" "" { target *-*-* } {.-1} } */ } void other_thing_caller () { other_thing (); } task yet_another_thing (auto) { co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ co_await nodiscardable{}; /* { dg-warning "attribute 'nodiscard'" } */ (void) co_await nodiscardable{}; (void) co_await nodiscardable{}; co_await discardable{}; co_await discardable{}; /* { dg-warning "implicit dereference will not access" "" { target *-*-* } {.-1} } */ } void yet_another_thing_caller () { yet_another_thing (1); }