From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 9CA253858C3B; Mon, 30 Aug 2021 21:25:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CA253858C3B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3235] c++: preserve location through constexpr X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: a8de832470f78a40a0e2c8de866a471bf74bf0ab X-Git-Newrev: 729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9 Message-Id: <20210830212521.9CA253858C3B@sourceware.org> Date: Mon, 30 Aug 2021 21:25:21 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 21:25:21 -0000 https://gcc.gnu.org/g:729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9 commit r12-3235-g729f6881cfcc6df3c15a1dd4ebd45bc46bb8f3e9 Author: Jason Merrill Date: Sat Aug 28 00:40:29 2021 -0400 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: --- gcc/cp/constexpr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9606719bc73..e78fdf021b2 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; }