diff options
author | Jason Merrill <jason@redhat.com> | 2021-08-28 00:40:29 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-08-30 17:23:38 -0400 |
commit | 729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9 (patch) | |
tree | d84d97a93a53a93c5ff8e288eb043a0abba7ba40 /gcc/cp/constexpr.c | |
parent | a8de832470f78a40a0e2c8de866a471bf74bf0ab (diff) | |
download | gcc-729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9.zip gcc-729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9.tar.gz gcc-729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9.tar.bz2 |
c++: preserve location through constexpr
While working on the patch for PR101460, I noticed that we were losing the
expression location when folding class prvalue expressions. The final patch
doesn't fold class prvalues, but this still seems a worthwhile change. I
don't add location wrappers for scalar prvalues because many callers are
trying to fold them away.
gcc/cp/ChangeLog:
* constexpr.c (cxx_eval_outermost_constant_expr): Copy
expr location to result.
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r-- | gcc/cp/constexpr.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9606719..e78fdf0 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -7445,6 +7445,11 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant, } } + /* Remember the original location if that wouldn't need a wrapper. */ + if (location_t loc = EXPR_LOCATION (t)) + if (CAN_HAVE_LOCATION_P (r)) + SET_EXPR_LOCATION (r, loc); + return r; } |