+2020-05-01 Jason Merrill <jason@redhat.com>
+
+ PR c++/93822
+ * pt.c (tsubst_decl): Make sure DECL_VALUE_EXPR continues to have
+ the same type as the variable.
+
2020-04-30 Jason Merrill <jason@redhat.com>
Nathan Sidwell <nathan@acm.org>
if (DECL_HAS_VALUE_EXPR_P (t))
{
tree ve = DECL_VALUE_EXPR (t);
+ /* If the DECL_VALUE_EXPR is converted to the declared type,
+ preserve the identity so that gimplify_type_sizes works. */
+ bool nop = (TREE_CODE (ve) == NOP_EXPR);
+ if (nop)
+ ve = TREE_OPERAND (ve, 0);
ve = tsubst_expr (ve, args, complain, in_decl,
/*constant_expression_p=*/false);
if (REFERENCE_REF_P (ve))
gcc_assert (TYPE_REF_P (type));
ve = TREE_OPERAND (ve, 0);
}
+ if (nop)
+ ve = build_nop (type, ve);
+ else
+ gcc_checking_assert (TREE_TYPE (ve) == type);
SET_DECL_VALUE_EXPR (r, ve);
}
if (CP_DECL_THREAD_LOCAL_P (r)