From 6ac6529e155c9baa0aaaed7aca06bd38ebda5b43 Mon Sep 17 00:00:00 2001 From: JunMa Date: Tue, 21 Jan 2020 10:29:34 +0800 Subject: [PATCH] Add error check on return value of build_co_await gcc/cp/ChangeLog * coroutines.cc (finish_co_await_expr): Add error check on return value of build_co_await. (finish_co_yield_expr): Ditto. --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/coroutines.cc | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3f379d0d996..4c195c48b03 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-22 Jun Ma + + * coroutines.cc (finish_co_await_expr): Add error check on return + value of build_co_await. + (finish_co_yield_expr,): Ditto. + 2020-01-22 Jun Ma * coroutines.cc (lookup_awaitable_member): Lookup an awaitable member. diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 6381fdc2f11..81fb8c924a7 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -819,8 +819,11 @@ finish_co_await_expr (location_t kw, tree expr) /* Now we want to build co_await a. */ tree op = build_co_await (kw, a, CO_AWAIT_SUSPEND_POINT); - TREE_SIDE_EFFECTS (op) = 1; - SET_EXPR_LOCATION (op, kw); + if (op != error_mark_node) + { + TREE_SIDE_EFFECTS (op) = 1; + SET_EXPR_LOCATION (op, kw); + } return op; } @@ -885,9 +888,11 @@ finish_co_yield_expr (location_t kw, tree expr) promise transform_await(). */ tree op = build_co_await (kw, yield_call, CO_YIELD_SUSPEND_POINT); - - op = build2_loc (kw, CO_YIELD_EXPR, TREE_TYPE (op), expr, op); - TREE_SIDE_EFFECTS (op) = 1; + if (op != error_mark_node) + { + op = build2_loc (kw, CO_YIELD_EXPR, TREE_TYPE (op), expr, op); + TREE_SIDE_EFFECTS (op) = 1; + } return op; } -- 2.30.2