// { dg-additional-options "-fcontracts -fcontract-continuation-mode=on" } // { dg-do run } // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } } #include #include template struct generator { struct promise_type { std::suspend_always yield_value(T) { return {}; } std::suspend_always initial_suspend() const noexcept { return {}; } std::suspend_never final_suspend() const noexcept { return {}; } void unhandled_exception() noexcept {} generator get_return_object() noexcept { return {}; } }; bool is_valid() { return false; } }; namespace std { template struct coroutine_traits, Args...> { using promise_type = typename generator::promise_type; }; }; generator val(int v) [[post g: g.is_valid()]] { std::cout << "coro initial" << std::endl; co_yield v; std::cout << "coro resumed" << std::endl; } int main() { std::cout << "main initial" << std::endl; generator s = val(1); (void)s; std::cout << "main continues" << std::endl; } // { dg-output "contract violation in function val at .*.C:36: g.is_valid().*(\n|\r\n|\r)" }