If the initializer is a conditional expression, we need to collect
and declare any promoted variables nested within it. DTORs for such
variables must be run conditionally too. */
- if (t->var && DECL_NAME (t->var))
+ if (t->var)
{
tree var = t->var;
DECL_CHAIN (var) = vlist;
tree b_vars = BIND_EXPR_VARS (bind);
/* Build a variable to hold the condition, this will be included in the
frame as a local var. */
- char *nam = xasprintf ("%s.%d", nam_root, nam_vers);
+ char *nam = xasprintf ("__%s_%d", nam_root, nam_vers);
tree newvar = build_lang_decl (VAR_DECL, get_identifier (nam), var_type);
free (nam);
DECL_CHAIN (newvar) = b_vars;
scopes with identically named locals and still be able to
identify them in the coroutine frame. */
tree lvname = DECL_NAME (lvar);
- char *buf;
+ char *buf = NULL;
/* The outermost bind scope contains the artificial variables that
we inject to implement the coro state machine. We want to be able
else if (lvname != NULL_TREE)
buf = xasprintf ("%s_%u_%u", IDENTIFIER_POINTER (lvname),
lvd->nest_depth, lvd->bind_indx);
- else
- buf = xasprintf ("_D%u_%u_%u", DECL_UID (lvar), lvd->nest_depth,
- lvd->bind_indx);
/* TODO: Figure out if we should build a local type that has any
excess alignment or size from the original decl. */
- local_var.field_id
- = coro_make_frame_entry (lvd->field_list, buf, lvtype, lvd->loc);
- free (buf);
+ if (buf)
+ {
+ local_var.field_id = coro_make_frame_entry (lvd->field_list, buf,
+ lvtype, lvd->loc);
+ free (buf);
+ }
/* We don't walk any of the local var sub-trees, they won't contain
any bind exprs. */
}
--- /dev/null
+// { dg-additional-options "-fanalyzer" }
+// { dg-excess-errors "lots of analyzer output, but no ICE" }
+namespace std {
+template <typename _Result> struct coroutine_traits : _Result {};
+template <typename = void> struct coroutine_handle {
+ operator coroutine_handle<>();
+};
+}
+struct coro1 {
+ using handle_type = std::coroutine_handle<>;
+ coro1(handle_type);
+ struct suspend_always_prt {
+ bool await_ready() noexcept;
+ void await_suspend(handle_type) noexcept;
+ void await_resume() noexcept;
+ };
+ struct promise_type {
+ std::coroutine_handle<> ch_;
+ auto get_return_object() { return ch_; }
+ auto initial_suspend() { return suspend_always_prt{}; }
+ auto final_suspend() noexcept { return suspend_always_prt{}; }
+ void unhandled_exception();
+ };
+};
+struct BoolAwaiter {
+ BoolAwaiter(bool);
+ bool await_ready();
+ void await_suspend(std::coroutine_handle<>);
+ bool await_resume();
+};
+struct IntAwaiter {
+ IntAwaiter(int);
+ bool await_ready();
+ void await_suspend(std::coroutine_handle<>);
+ int await_resume();
+};
+coro1 my_coro() {
+ int a = 1;
+ if (a == 0) {
+ int b = 5;
+
+ }
+ {
+ int c = 10;
+ }
+ co_await BoolAwaiter(true) && co_await IntAwaiter(a);
+
+ }