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/fold-const.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/fold-const.cc')
-rw-r--r-- | gcc/fold-const.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index e4c43fb..42547f4 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -164,7 +164,7 @@ expr_location_or (tree t, location_t loc) /* Similar to protected_set_expr_location, but never modify x in place, if location can and needs to be set, unshare it. */ -static inline tree +tree protected_set_expr_location_unshare (tree x, location_t loc) { if (CAN_HAVE_LOCATION_P (x) |