diff options
author | Jason Merrill <jason@redhat.com> | 2022-12-01 22:58:28 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-12-20 21:01:44 -0500 |
commit | 302485a70a33f3a86e85ad9051de2b51c5dc0bc0 (patch) | |
tree | 534f842bc26f4d4d286508c401f22d56b97abdab /gcc/tree.cc | |
parent | a996888327c2248b59db7244333740c2b51578c9 (diff) | |
download | gcc-302485a70a33f3a86e85ad9051de2b51c5dc0bc0.zip gcc-302485a70a33f3a86e85ad9051de2b51c5dc0bc0.tar.gz gcc-302485a70a33f3a86e85ad9051de2b51c5dc0bc0.tar.bz2 |
c++: source position of lambda captures [PR84471]
If the DECL_VALUE_EXPR of a VAR_DECL has EXPR_LOCATION set, then any use of
that variable looks like it has that location, which leads to the debugger
jumping back and forth for both lambdas and structured bindings.
Rather than fix all the uses, it seems simplest to remove any EXPR_LOCATION
when setting DECL_VALUE_EXPR. So the cp/ hunks aren't necessary, but they
avoid the need to unshare to remove the location.
PR c++/84471
PR c++/107504
gcc/cp/ChangeLog:
* coroutines.cc (transform_local_var_uses): Don't
specify a location for DECL_VALUE_EXPR.
* decl.cc (cp_finish_decomp): Likewise.
gcc/ChangeLog:
* fold-const.cc (protected_set_expr_location_unshare): Not static.
* tree.h: Declare it.
* tree.cc (decl_value_expr_insert): Use it.
include/ChangeLog:
* ansidecl.h (ATTRIBUTE_WARN_UNUSED_RESULT): Add __.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/value-expr1.C: New test.
* g++.dg/tree-ssa/value-expr2.C: New test.
* g++.dg/analyzer/pr93212.C: Move warning.
Diffstat (limited to 'gcc/tree.cc')
-rw-r--r-- | gcc/tree.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/tree.cc b/gcc/tree.cc index 92199bb..581d448 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -5862,6 +5862,9 @@ decl_value_expr_insert (tree from, tree to) { struct tree_decl_map *h; + /* Uses of FROM shouldn't look like they happen at the location of TO. */ + to = protected_set_expr_location_unshare (to, UNKNOWN_LOCATION); + h = ggc_alloc<tree_decl_map> (); h->base.from = from; h->to = to; |