aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-typeck.c18
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr83547.c16
-rw-r--r--gcc/tree-iterator.c5
6 files changed, 45 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a75db07..aba9ae7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2017-12-22 Jakub Jelinek <jakub@redhat.com>
+ 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.
+
PR target/83488
* config/i386/avx512vnniintrin.h: Don't check for __AVX512F__ nor
enable avx512f explicitly in #pragma GCC target.
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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 297e80f..0102564 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2017-12-22 Jakub Jelinek <jakub@redhat.com>
+ PR debug/83547
+ * gcc.c-torture/compile/pr83547.c: New test.
+
PR target/83488
* gcc.target/i386/pr83488-2.c: New test.
* gcc.target/i386/pr83488-3.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83547.c b/gcc/testsuite/gcc.c-torture/compile/pr83547.c
new file mode 100644
index 0000000..98a1e04
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr83547.c
@@ -0,0 +1,16 @@
+/* PR debug/83547 */
+
+void
+foo (void)
+{
+ if (({ 0; }))
+ ;
+ if (({ 0; 0; }))
+ ;
+ if (({ })) /* { dg-error "void value not ignored as it ought to be" } */
+ ;
+ if (({ 0; { 0; } })) /* { dg-error "void value not ignored as it ought to be" } */
+ ;
+ if (({ 0; {} })) /* { dg-error "void value not ignored as it ought to be" } */
+ ;
+}
diff --git a/gcc/tree-iterator.c b/gcc/tree-iterator.c
index 10e510d..b0b88f4 100644
--- a/gcc/tree-iterator.c
+++ b/gcc/tree-iterator.c
@@ -41,7 +41,10 @@ alloc_stmt_list (void)
TREE_SET_CODE (list, STATEMENT_LIST);
}
else
- list = make_node (STATEMENT_LIST);
+ {
+ list = make_node (STATEMENT_LIST);
+ TREE_SIDE_EFFECTS (list) = 0;
+ }
TREE_TYPE (list) = void_type_node;
return list;
}