aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-26 09:18:35 +0100
committerJakub Jelinek <jakub@redhat.com>2020-03-26 09:18:35 +0100
commit5a1706f63a2024a5c2d878f2efeb8d198214542f (patch)
tree15b61f1bd3c5c3388f4c53a04c010afe1bb682db /gcc/tree.c
parent9708ca2be40399d6266bc85c99e085e3fe27a809 (diff)
downloadgcc-5a1706f63a2024a5c2d878f2efeb8d198214542f.zip
gcc-5a1706f63a2024a5c2d878f2efeb8d198214542f.tar.gz
gcc-5a1706f63a2024a5c2d878f2efeb8d198214542f.tar.bz2
c++: Fix a -fcompare-debug issue with DEBUG_BEGIN_STMT stmts in STATEMENT_LISTs [PR94272]
The following testcase FAILs with -fcompare-debug. The problem is that the C++ FE initially uses IF_STMTs, tcc_statement which default to TREE_SIDE_EFFECTS set, but later on is genericized into COND_EXPRs, tcc_expression which default to TREE_SIDE_EFFECTS ored from all 3 operands. Furthermore, with -g we emit by default DEBUG_BEGIN_STMTs (TREE_SIDE_EFFECTS clear) and so end up with a STATEMENT_LIST containing DEBUG_BEGIN_STMT + e.g. the IF_STMT, while with -g0 we would end up with just the IF_STMT alone and in that case there is no STATEMENT_LIST wrapping it. Now, the STATEMENT_LIST has TREE_SIDE_EFFECTS set to match the IF_STMT, but if none of the 3 operands (condition and both branches) have TREE_SIDE_EFFECTS, genericize_if_stmt will replace the IF_STMT with COND_EXPR without TREE_SIDE_EFFECTS, but with -g only STATEMENT_LIST wrapping it will keep TREE_SIDE_EFFECTS. Then during gimplification, shortcut_cond_expr checks TREE_SIDE_EFFECTS of the operands and as it is differennt between -g and -g0, will generate different code. The following patch attempts to fix this by clearing TREE_SIDE_EFFECTS on STATEMENT_LISTs that initially have it set and contain only DEBUG_BEGIN_STMT or at most one other statement that lost TREE_SIDE_EFFECTS during the genericization. 2020-03-26 Jakub Jelinek <jakub@redhat.com> PR c++/94272 * cp-gimplify.c (cp_genericize_r): Handle STATEMENT_LIST. * g++.dg/debug/pr94272.C: New test.
Diffstat (limited to 'gcc/tree.c')
0 files changed, 0 insertions, 0 deletions