From: Jason Merrill Date: Sat, 28 Aug 2021 04:40:29 +0000 (-0400) Subject: c++: preserve location through constexpr X-Git-Tag: basepoints/gcc-13~5078 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9606719bc739..e78fdf021b23 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; }