https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127478
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch here. Best to fix it after P4101 though.
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index d0f4ace8566..95503276e8b 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -11663,7 +11663,8 @@ cxx_eval_outermost_constant_expr (tree t, bool
allow_non_constant,
if (throws (&jmp_target) && !non_constant_p)
{
if (!ctx.quiet)
- diagnose_uncaught_exception (input_location, &ctx, jmp_target);
+ diagnose_uncaught_exception (cp_expr_loc_or_input_loc (t), &ctx,
+ jmp_target);
non_constant_p = true;
jmp_target = NULL_TREE;
r = t;
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index de265297e40..53d965c0c9c 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1130,10 +1130,7 @@ store_init_value (tree decl, tree init, vec<tree,
va_gc>** cleanups, int flags)
because they have already been constant-evaluated and we don't want the
"uses a consteval-only value" error because the initializer is an MCE
context. */
- if ((!current_function_decl
- || !maybe_constexpr_fn (current_function_decl)
- || TREE_STATIC (decl))
- && !DECL_DECLARED_CONSTEXPR_P (decl))
+ if (TREE_STATIC (decl) && !DECL_DECLARED_CONSTEXPR_P (decl))
value = cp_fully_fold_init (value, decl);
/* Handle aggregate NSDMI in non-constant initializers, too. */
@@ -1143,6 +1140,8 @@ store_init_value (tree decl, tree init, vec<tree,
va_gc>** cleanups, int flags)
recursively convert them into STRING_CSTs. */
value = braced_lists_to_strings (type, value);
+ STRIP_ANY_LOCATION_WRAPPER (value);
+
/* Detect stuff like 'info r = ^^int;' outside a manifestly
constant-evaluated context. Also detect 'auto p = &consteval_fn'. */
if (!processing_template_decl