aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/debug/pr94323.C13
-rw-r--r--gcc/tree.c27
4 files changed, 49 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8005e1a..cc7f4d4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2020-03-26 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94323
+ * tree.c (protected_set_expr_location): Recurse on STATEMENT_LIST
+ that contains exactly one non-DEBUG_BEGIN_STMT statement.
+
PR debug/94281
* gimple.h (gimple_seq_first_nondebug_stmt): New function.
(gimple_seq_last_nondebug_stmt): Don't return NULL if seq contains
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 65f32a3..4d73d48 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/94323
+ * g++.dg/debug/pr94323.C: New test.
+
2020-03-26 Martin Liska <mliska@suse.cz>
PR testsuite/94334
diff --git a/gcc/testsuite/g++.dg/debug/pr94323.C b/gcc/testsuite/g++.dg/debug/pr94323.C
new file mode 100644
index 0000000..eac81a3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr94323.C
@@ -0,0 +1,13 @@
+// PR debug/94323
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+
+volatile int a;
+
+void
+foo ()
+{
+ ({
+ a;
+ });
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index f38dfff..63dc673 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5146,6 +5146,33 @@ protected_set_expr_location (tree t, location_t loc)
{
if (CAN_HAVE_LOCATION_P (t))
SET_EXPR_LOCATION (t, loc);
+ else if (t && TREE_CODE (t) == STATEMENT_LIST)
+ {
+ /* With -gstatement-frontiers we could have a STATEMENT_LIST with
+ DEBUG_BEGIN_STMT(s) and only a single other stmt, which with
+ -g wouldn't be present and we'd have that single other stmt
+ directly instead. */
+ struct tree_statement_list_node *n = STATEMENT_LIST_HEAD (t);
+ if (!n)
+ return;
+ while (TREE_CODE (n->stmt) == DEBUG_BEGIN_STMT)
+ {
+ n = n->next;
+ if (!n)
+ return;
+ }
+ tree t2 = n->stmt;
+ do
+ {
+ n = n->next;
+ if (!n)
+ {
+ protected_set_expr_location (t2, loc);
+ return;
+ }
+ }
+ while (TREE_CODE (n->stmt) == DEBUG_BEGIN_STMT);
+ }
}
/* Data used when collecting DECLs and TYPEs for language data removal. */