aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-12-22 19:01:58 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-12-22 19:01:58 +0100
commit11d29d639f4b60f51a593932529be6895b613d4c (patch)
tree55a89f9b5c3f9d9950784154e055bf77d09d5457 /gcc/c
parentd7727ce400380aaf26fb915d31dcbd98a761e2c0 (diff)
downloadgcc-11d29d639f4b60f51a593932529be6895b613d4c.zip
gcc-11d29d639f4b60f51a593932529be6895b613d4c.tar.gz
gcc-11d29d639f4b60f51a593932529be6895b613d4c.tar.bz2
re PR debug/83547 ((statement-frontiers) error: void value not ignored as it ought to be)
PR debug/83547 * tree-iterator.c (alloc_stmt_list): Start with cleared TREE_SIDE_EFFECTS regardless whether a new STATEMENT_LIST is allocated or old one reused. c/ * c-typeck.c (c_finish_stmt_expr): Ignore !TREE_SIDE_EFFECTS as indicator of ({ }), instead skip all trailing DEBUG_BEGIN_STMTs first, and consider empty ones if there are no other stmts. For -Wunused-value walk all statements before the one only followed by DEBUG_BEGIN_STMTs. testsuite/ * gcc.c-torture/compile/pr83547.c: New test. From-SVN: r255980
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-typeck.c18
2 files changed, 17 insertions, 10 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index f4756c8..581f7df 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2017-12-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/83547
+ * c-typeck.c (c_finish_stmt_expr): Ignore !TREE_SIDE_EFFECTS as
+ indicator of ({ }), instead skip all trailing DEBUG_BEGIN_STMTs first,
+ and consider empty ones if there are no other stmts. For
+ -Wunused-value walk all statements before the one only followed by
+ DEBUG_BEGIN_STMTs.
+
2017-12-22 Mike Stump <mikestump@comcast.net>
Eric Botcazou <ebotcazou@adacore.com>
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 5ae12d9..98062c7 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -10751,17 +10751,21 @@ c_finish_stmt_expr (location_t loc, tree body)
continue_searching:
if (TREE_CODE (last) == STATEMENT_LIST)
{
- tree_stmt_iterator i;
+ tree_stmt_iterator l = tsi_last (last);
+
+ while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
+ tsi_prev (&l);
/* This can happen with degenerate cases like ({ }). No value. */
- if (!TREE_SIDE_EFFECTS (last))
+ if (tsi_end_p (l))
return body;
/* If we're supposed to generate side effects warnings, process
all of the statements except the last. */
if (warn_unused_value)
{
- for (i = tsi_start (last); !tsi_one_before_end_p (i); tsi_next (&i))
+ for (tree_stmt_iterator i = tsi_start (last);
+ tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
{
location_t tloc;
tree t = tsi_stmt (i);
@@ -10770,13 +10774,7 @@ c_finish_stmt_expr (location_t loc, tree body)
emit_side_effect_warnings (tloc, t);
}
}
- else
- i = tsi_last (last);
- if (TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT)
- do
- tsi_prev (&i);
- while (TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT);
- last_p = tsi_stmt_ptr (i);
+ last_p = tsi_stmt_ptr (l);
last = *last_p;
}