+2017-11-13 Jason Merrill <jason@redhat.com>
+
+ PR c++/82360 - ICE with static_cast in template.
+ * call.c (perform_direct_initialization_if_possible): Check
+ processing_template_decl.
+ * typeck.c (build_static_cast_1): Likewise.
+
2017-11-13 Ville Voutilainen <ville.voutilainen@gmail.com>
Remove the null check from placement new in all modes
LOOKUP_NORMAL, complain);
if (!conv || conv->bad_p)
expr = NULL_TREE;
+ else if (processing_template_decl && conv->kind != ck_identity)
+ {
+ /* In a template, we are only concerned about determining the
+ type of non-dependent expressions, so we do not have to
+ perform the actual conversion. But for initializers, we
+ need to be able to perform it at instantiation
+ (or instantiate_non_dependent_expr) time. */
+ expr = build1 (IMPLICIT_CONV_EXPR, type, expr);
+ IMPLICIT_CONV_EXPR_DIRECT_INIT (expr) = true;
+ }
else
expr = convert_like_real (conv, expr, NULL_TREE, 0,
/*issue_conversion_warnings=*/false,
{
tree base;
+ if (processing_template_decl)
+ return expr;
+
/* There is a standard conversion from "D*" to "B*" even if "B"
is ambiguous or inaccessible. If this is really a
static_cast, then we check both for inaccessibility and
&& reference_related_p (TREE_TYPE (type), intype)
&& (c_cast_p || at_least_as_qualified_p (TREE_TYPE (type), intype)))
{
+ if (processing_template_decl)
+ return expr;
if (clk == clk_ordinary)
{
/* Handle the (non-bit-field) lvalue case here by casting to
c_cast_p, complain);
if (result)
{
+ if (processing_template_decl)
+ return expr;
+
result = convert_from_reference (result);
/* [expr.static.cast]
|| SCALAR_FLOAT_TYPE_P (type))
&& (INTEGRAL_OR_ENUMERATION_TYPE_P (intype)
|| SCALAR_FLOAT_TYPE_P (intype)))
- return ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL, complain);
+ {
+ if (processing_template_decl)
+ return expr;
+ return ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL, complain);
+ }
if (TYPE_PTR_P (type) && TYPE_PTR_P (intype)
&& CLASS_TYPE_P (TREE_TYPE (type))
{
tree base;
+ if (processing_template_decl)
+ return expr;
+
if (!c_cast_p
&& check_for_casting_away_constness (intype, type, STATIC_CAST_EXPR,
complain))
STATIC_CAST_EXPR,
complain))
return error_mark_node;
+ if (processing_template_decl)
+ return expr;
return convert_ptrmem (type, expr, /*allow_inverse_p=*/1,
c_cast_p, complain);
}
&& check_for_casting_away_constness (intype, type, STATIC_CAST_EXPR,
complain))
return error_mark_node;
+ if (processing_template_decl)
+ return expr;
return build_nop (type, expr);
}