{
/* Avoid the code here attaching a location that makes the debugger jump. */
iloc_sentinel stable_input_loc (fn_start);
- location_t loc = UNKNOWN_LOCATION;
- input_location = loc;
+ location_t loc = fn_start;
/* This will be our new outer scope. */
tree update_body
/* If the coroutine has a frame that needs to be freed, this will be set by
the ramp. */
- var = coro_build_artificial_var (fn_start, coro_frame_needs_free_id,
+ var = coro_build_artificial_var (loc, coro_frame_needs_free_id,
boolean_type_node, orig_fn_decl, NULL_TREE);
DECL_CHAIN (var) = var_list;
var_list = var;
tree ueh
= coro_build_promise_expression (orig_fn_decl, promise,
coro_unhandled_exception_identifier,
- fn_start, NULL, /*musthave=*/true);
+ loc, NULL, /*musthave=*/true);
/* Create and initialize the initial-await-resume-called variable per
[dcl.fct.def.coroutine] / 5.3. */
tree i_a_r_c
tree ueh_meth
= lookup_promise_method (orig_fn_decl,
coro_unhandled_exception_identifier,
- fn_start, /*musthave=*/false);
+ loc, /*musthave=*/false);
if (!ueh_meth || ueh_meth == error_mark_node)
- warning_at (fn_start, 0, "no member named %qE in %qT",
+ warning_at (loc, 0, "no member named %qE in %qT",
coro_unhandled_exception_identifier,
get_coroutine_promise_type (orig_fn_decl));
}
add_stmt (return_void);
}
+ /* We are now doing actions associated with the end of the function, so
+ point to the closing brace. */
+ input_location = loc = fn_end;
+
/* co_return branches to the final_suspend label, so declare that now. */
fs_label
= create_named_label_with_ctx (loc, "final.suspend", NULL_TREE);
--- /dev/null
+// PR120273
+// { dg-additional-options "-Wno-literal-suffix" }
+namespace std {
+void declval();
+template < typename > struct invoke_result;
+template < typename _Fn > using invoke_result_t = invoke_result< _Fn >;
+template < typename _Derived, typename _Base >
+concept derived_from = __is_base_of(_Base, _Derived);
+template < typename, typename >
+concept convertible_to = requires { declval; };
+template < char... > int operator""ms();
+template < typename _Result, typename > struct coroutine_traits : _Result {};
+template < typename = void > struct coroutine_handle {
+ static coroutine_handle from_address(void *);
+ operator coroutine_handle<>();
+ void *address();
+};
+}
+
+using namespace std;
+
+template < class > using CoroutineHandle = coroutine_handle<>;
+
+template < class Callable >
+ requires(derived_from< invoke_result_t< Callable >, int >)
+Callable operator co_await(Callable);
+
+struct FinalSuspendProxy {
+ bool await_ready() noexcept;
+ void await_suspend(CoroutineHandle< void >) noexcept ;
+ void await_resume() noexcept;
+};
+
+struct Task {
+ struct Promise;
+ using promise_type = Promise;
+
+ struct Promise {
+ auto initial_suspend() { return FinalSuspendProxy(); }
+ auto final_suspend () noexcept { return FinalSuspendProxy(); }
+ void unhandled_exception () {}
+ Task get_return_object () { return {}; }
+ };
+} ;
+
+struct TestEventLoop {
+ struct Sleep {
+ Sleep(TestEventLoop, int);
+ bool await_ready();
+ void await_suspend(CoroutineHandle< void >);
+ void await_resume();
+ };
+ auto sleep(int tm) { return Sleep(*this, tm); }
+};
+
+Task test_body_11(TestEventLoop t) {
+ co_await t.sleep(5ms);
+}