When flatten_await_stmt processes the backing array for an initializer_list,
we call cp_build_modify_expr to initialize the promoted variable from the
TARGET_EXPR; that needs to be accepted.
PR c++/103871
PR c++/98056
gcc/cp/ChangeLog:
* typeck.cc (cp_build_modify_expr): Allow array initialization of
DECL_ARTIFICIAL variable.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/co-await-initlist1.C: New test.
}
/* Allow array assignment in compiler-generated code. */
+ else if (DECL_P (lhs) && DECL_ARTIFICIAL (lhs))
+ /* OK, used by coroutines (co-await-initlist1.C). */;
else if (!current_function_decl
|| !DECL_DEFAULTED_FN (current_function_decl))
{
--- /dev/null
+// PR c++/103871
+// { dg-do compile { target c++20 } }
+
+#include <coroutine>
+#include <initializer_list>
+
+struct my_coro {
+ struct promise_type {
+ my_coro get_return_object();
+ std::suspend_never initial_suspend();
+ std::suspend_never final_suspend() noexcept;
+ void unhandled_exception();
+ };
+};
+
+std::suspend_never inner(std::initializer_list<int>);
+
+my_coro doesnt_work()
+{
+ co_await inner({ 1,2,3 });
+}