aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-05-30 17:03:40 +0100
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:09:25 -0300
commitb0f06e250264df26f8086ceadfb9ffe2b25c2e4e (patch)
tree154bbd6e7a7aeb52ab6b5b9417011bad7efffdb5 /gcc
parent85169d9f15c3e16df5802cb3a9e90e10746f2a3d (diff)
downloadgcc-b0f06e250264df26f8086ceadfb9ffe2b25c2e4e.zip
gcc-b0f06e250264df26f8086ceadfb9ffe2b25c2e4e.tar.gz
gcc-b0f06e250264df26f8086ceadfb9ffe2b25c2e4e.tar.bz2
coroutines: Fix unused value found by static analysis.
This fixes up the zero-initialization of the coro frame pointer to avoid an unused assigned value, spotted by Martin Liska with static analysis. gcc/cp/ChangeLog: * coroutines.cc (morph_fn_to_coro): Revise initialization of the frame pointer to avoid an unused value.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/coroutines.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index b79e2c6..c4df488 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3889,11 +3889,9 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
/* The decl_expr for the coro frame pointer, initialize to zero so that we
can pass it to the IFN_CO_FRAME (since there's no way to pass a type,
directly apparently). This avoids a "used uninitialized" warning. */
- tree r = build_stmt (fn_start, DECL_EXPR, coro_fp);
tree zeroinit = build1 (CONVERT_EXPR, coro_frame_ptr, integer_zero_node);
- r = build2 (INIT_EXPR, TREE_TYPE (coro_fp), coro_fp, zeroinit);
- r = coro_build_cvt_void_expr_stmt (r, fn_start);
- add_stmt (r);
+ DECL_INITIAL (coro_fp) = zeroinit;
+ add_decl_expr (coro_fp);
/* The CO_FRAME internal function is a mechanism to allow the middle end
to adjust the allocation in response to optimisations. We provide the
@@ -4047,7 +4045,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
}
tree allocated = build1 (CONVERT_EXPR, coro_frame_ptr, new_fn);
- r = build2 (INIT_EXPR, TREE_TYPE (coro_fp), coro_fp, allocated);
+ tree r = build2 (INIT_EXPR, TREE_TYPE (coro_fp), coro_fp, allocated);
r = coro_build_cvt_void_expr_stmt (r, fn_start);
add_stmt (r);