On Mon, Aug 30, 2021 at 05:25:01PM -0400, Jason Merrill via Gcc-patches wrote:
> 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.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.
> 
> gcc/cp/ChangeLog:
> 
>       * constexpr.c (cxx_eval_outermost_constant_expr): Copy
>       expr location to result.
> ---
>  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);

Can we use protected_set_expr_location or did you not want that?

Marek

Reply via email to