aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-semantics.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2017-12-21 18:14:06 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2017-12-21 18:14:06 +0000
commitcb6332333854a698cbfc2ea4b1e52ce9bd59f664 (patch)
tree1fc2746b579d67b45f98cfb65ac4f0839237650a /gcc/c-family/c-semantics.c
parent6b6d8f38f7b3bd8a2f4e4dbeb3014ba1339afa89 (diff)
downloadgcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.zip
gcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.tar.gz
gcc-cb6332333854a698cbfc2ea4b1e52ce9bd59f664.tar.bz2
[SFN] propagate single-nondebug-stmt's side effects to enclosing list
Statements without side effects, preceded by debug begin stmt markers, would become a statement list with side effects, although the stmt on its own would be extracted from the list and remain not having side effects. This causes debug info and possibly codegen differences. This patch fixes it, identifying the situation in which the stmt would have been extracted from the stmt list, and propagating the side effects flag from the stmt to the list. for gcc/ChangeLog PR debug/83419 * c-family/c-semantics.c (pop_stmt_list): Propagate side effects from single nondebug stmt to container list. for gcc/testsuite/ChangeLog PR debug/83419 * gcc.dg/pr83419.c: New. From-SVN: r255947
Diffstat (limited to 'gcc/c-family/c-semantics.c')
-rw-r--r--gcc/c-family/c-semantics.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c
index cd872d8..3a972c3 100644
--- a/gcc/c-family/c-semantics.c
+++ b/gcc/c-family/c-semantics.c
@@ -96,6 +96,15 @@ pop_stmt_list (tree t)
t = l;
tsi_link_before (&i, u, TSI_SAME_STMT);
}
+ 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
+ TREE_SIDE_EFFECTS in sync. */
+ if (tsi_one_before_end_p (i))
+ TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (tsi_stmt (i));
}
}