diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-04-04 09:16:07 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-04-04 09:16:07 +0200 |
commit | aae5d08a8d4dcee576a85ea76febe56c53675ef2 (patch) | |
tree | 994c134f624ee1e684e02604cb4efa1d7080e7bd /gcc/cp/cp-gimplify.c | |
parent | 78e276490953638f2e0694ea39dfa2818d6d2d7d (diff) | |
download | gcc-aae5d08a8d4dcee576a85ea76febe56c53675ef2.zip gcc-aae5d08a8d4dcee576a85ea76febe56c53675ef2.tar.gz gcc-aae5d08a8d4dcee576a85ea76febe56c53675ef2.tar.bz2 |
c++: Fix further protected_set_expr_location related -fcompare-debug issues [PR94441]
My recent protected_set_expr_location changes work well when
that function is called unconditionally, but as the testcase shows, the C++
FE has a few spots that do:
if (!EXPR_HAS_LOCATION (stmt))
protected_set_expr_location (stmt, locus);
or similar. Now, if we have for -g0 stmt of some expression that can
have location and has != UNKNOWN_LOCATION, while -g instead has
a STATEMENT_LIST containing some DEBUG_BEGIN_STMTs + that expression with
that location, we don't call protected_set_expr_location in the -g0 case,
but do call it in the -g case, because on the STATEMENT_LIST
!EXPR_HAS_LOCATION.
The following patch introduces a helper function which digs up the single
expression of a STATEMENT_LIST and uses that expression in the
EXPR_HAS_LOCATION check (plus changes protected_set_expr_location to
also use that helper).
Or do we want a further wrapper, perhaps C++ FE only, that would do this
protected_set_expr_location_if_unset (stmt, locus)?
2020-04-04 Jakub Jelinek <jakub@redhat.com>
PR debug/94441
* tree-iterator.h (expr_single): Declare.
* tree-iterator.c (expr_single): New function.
* tree.h (protected_set_expr_location_if_unset): Declare.
* tree.c (protected_set_expr_location): Use expr_single.
(protected_set_expr_location_if_unset): New function.
* parser.c (cp_parser_omp_for_loop): Use
protected_set_expr_location_if_unset.
* cp-gimplify.c (genericize_if_stmt, genericize_cp_loop): Likewise.
* g++.dg/opt/pr94441.C: New test.
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r-- | gcc/cp/cp-gimplify.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 3999695..f326d71 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -226,8 +226,7 @@ genericize_if_stmt (tree *stmt_p) stmt = else_; else stmt = build3 (COND_EXPR, void_type_node, cond, then_, else_); - if (!EXPR_HAS_LOCATION (stmt)) - protected_set_expr_location (stmt, locus); + protected_set_expr_location_if_unset (stmt, locus); *stmt_p = stmt; } @@ -248,8 +247,7 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body, tree stmt_list = NULL; tree debug_begin = NULL; - if (EXPR_LOCATION (incr) == UNKNOWN_LOCATION) - protected_set_expr_location (incr, start_locus); + protected_set_expr_location_if_unset (incr, start_locus); cp_walk_tree (&cond, cp_genericize_r, data, NULL); cp_walk_tree (&incr, cp_genericize_r, data, NULL); |