aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog8
-rw-r--r--gcc/c-family/c-semantics.c23
2 files changed, 27 insertions, 4 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 6f62034..ba61fce 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,11 @@
+2017-12-22 Alexandre Oliva <aoliva@redhat.com>
+
+ PR debug/83527
+ PR debug/83419
+ * c-semantics.c (only_debug_stmts_after_p): New.
+ (pop_stmt_list): Clear side effects in debug-only stmt list.
+ Check for single nondebug stmt followed by debug stmts only.
+
2017-12-21 Alexandre Oliva <aoliva@redhat.com>
PR debug/83419
diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c
index 3a972c3..21d908e 100644
--- a/gcc/c-family/c-semantics.c
+++ b/gcc/c-family/c-semantics.c
@@ -35,6 +35,17 @@ push_stmt_list (void)
return t;
}
+/* Return TRUE if, after I, there are any nondebug stmts. */
+
+static inline bool
+only_debug_stmts_after_p (tree_stmt_iterator i)
+{
+ for (tsi_next (&i); !tsi_end_p (i); tsi_next (&i))
+ if (TREE_CODE (tsi_stmt (i)) != DEBUG_BEGIN_STMT)
+ return false;
+ return true;
+}
+
/* Finish the statement tree rooted at T. */
tree
@@ -99,11 +110,15 @@ pop_stmt_list (tree t)
while (!tsi_end_p (i)
&& TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT)
tsi_next (&i);
- /* If there's only one nondebug stmt in the list, we'd have
- extracted the stmt and dropped the list, and we'd take
- TREE_SIDE_EFFECTS from that statement, so keep the list's
+ /* If there are only debug stmts in the list, without them
+ we'd have an empty stmt without side effects. If there's
+ only one nondebug stmt, we'd have extracted the stmt and
+ dropped the list, and we'd take TREE_SIDE_EFFECTS from
+ that statement. In either case, keep the list's
TREE_SIDE_EFFECTS in sync. */
- if (tsi_one_before_end_p (i))
+ if (tsi_end_p (i))
+ TREE_SIDE_EFFECTS (t) = 0;
+ else if (only_debug_stmts_after_p (i))
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (tsi_stmt (i));
}
}