+2020-03-03 Jun Ma <JunMa@linux.alibaba.com>
+
+ * coroutines.cc (finish_co_await_expr): Build co_await_expr
+ with unknown_type_node.
+ (finish_co_yield_expr): Ditto.
+ *pt.c (type_dependent_expression_p): Set co_await/yield_expr
+ with unknown type as dependent.
+
2020-03-02 Iain Sandoe <iain@sandoe.co.uk>
* coroutines.cc (struct local_var_info): Adjust to remove the
/* If we don't know the promise type, we can't proceed. */
tree functype = TREE_TYPE (current_function_decl);
if (dependent_type_p (functype) || type_dependent_expression_p (expr))
- return build5_loc (kw, CO_AWAIT_EXPR, TREE_TYPE (expr), expr, NULL_TREE,
- NULL_TREE, NULL_TREE, integer_zero_node);
+ return build5_loc (kw, CO_AWAIT_EXPR, unknown_type_node, expr,
+ NULL_TREE, NULL_TREE, NULL_TREE, integer_zero_node);
}
/* We must be able to look up the "await_transform" method in the scope of
tree functype = TREE_TYPE (current_function_decl);
/* If we don't know the promise type, we can't proceed. */
if (dependent_type_p (functype) || type_dependent_expression_p (expr))
- return build2_loc (kw, CO_YIELD_EXPR, TREE_TYPE (expr), expr,
+ return build2_loc (kw, CO_YIELD_EXPR, unknown_type_node, expr,
NULL_TREE);
}
if (TREE_CODE (expression) == SCOPE_REF)
return false;
+ /* CO_AWAIT/YIELD_EXPR with unknown type is always dependent. */
+ if (TREE_CODE (expression) == CO_AWAIT_EXPR
+ || TREE_CODE (expression) == CO_YIELD_EXPR)
+ return true;
+
if (BASELINK_P (expression))
{
if (BASELINK_OPTYPE (expression)
+2020-03-03 Jun Ma <JunMa@linux.alibaba.com>
+
+ * g++.dg/coroutines/torture/co-await-14-template-traits.C: New test.
+
2020-03-02 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/analyzer/CVE-2005-1689-dedupe-issue.c: Add
--- /dev/null
+// { dg-do compile }
+// Test we create co_await_expr with dependent type rather than type of awaitable class
+
+#include "../coro.h"
+#include "../coro1-ret-int-yield-int.h"
+#include <chrono>
+
+struct TestAwaiter {
+ int recent_test;
+ TestAwaiter(int test) : recent_test{test} {}
+ bool await_ready() { return true; }
+ void await_suspend(coro::coroutine_handle<>) {}
+ int await_resume() { return recent_test;}
+ void return_value(int x) { recent_test = x;}
+};
+
+template <typename Rep, typename Period>
+coro1 test_temparg (std::chrono::duration<Rep, Period> dur)
+{
+ auto sum = co_await TestAwaiter(1);
+ if (!sum)
+ dur.count();
+ co_return 0;
+}