We do not support it currently, and the resulting memory can only be
used inside a single resumption, so best not confuse the user with it.
PR c++/115858 - Incompatibility of coroutines and alloca()
gcc/ChangeLog:
* coroutine-passes.cc (execute_early_expand_coro_ifns): Emit a
sorry if a statement is an alloca call.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr115858.C: New test.
#include "gimple.h"
#include "tree-pass.h"
#include "ssa.h"
+#include "calls.h"
#include "cgraph.h"
#include "pretty-print.h"
#include "diagnostic-core.h"
{
gimple *stmt = gsi_stmt (gsi);
+ /* Tell the user about 'alloca', we don't support it yet. */
+ if (gimple_alloca_call_p (stmt))
+ {
+ sorry_at (gimple_location (stmt),
+ "%<alloca%> is not yet supported in coroutines");
+ gsi_next (&gsi);
+ continue;
+ }
+
if (!is_gimple_call (stmt) || !gimple_call_internal_p (stmt))
{
gsi_next (&gsi);
--- /dev/null
+#include <coroutine>
+
+struct task
+{
+ struct promise_type
+ {
+ void return_void () {}
+ task get_return_object () { return {}; }
+ void unhandled_exception () {}
+ std::suspend_never initial_suspend () { return {}; }
+ std::suspend_never final_suspend () noexcept { return {}; }
+ };
+};
+
+task
+f ()
+{
+ void* a = __builtin_alloca (10);
+ // { dg-message "sorry, unimplemented: 'alloca' is not yet supported in coroutines" "" { target *-*-* } {.-1} }
+ void* b = __builtin_alloca_with_align (10, 16);
+ // { dg-message "sorry, unimplemented: 'alloca' is not yet supported in coroutines" "" { target *-*-* } {.-1} }
+ co_return;
+}