cvt.c (ocp_convert): Early handle the special case of a null_ptr_cst_p expr converted to a...

2018-05-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* cvt.c (ocp_convert): Early handle the special case of a
	null_ptr_cst_p expr converted to a NULLPTR_TYPE_P type.

From-SVN: r259966
This commit is contained in:
Paolo Carlini 2018-05-05 07:39:36 +00:00 committed by Paolo Carlini
parent c3f57fa100
commit 39d8c7d2c1
2 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2018-05-05 Paolo Carlini <paolo.carlini@oracle.com>
* cvt.c (ocp_convert): Early handle the special case of a
null_ptr_cst_p expr converted to a NULLPTR_TYPE_P type.
2018-05-03 Jason Merrill <jason@redhat.com>
PR c++/85600 - virtual delete failure.

View File

@ -711,6 +711,15 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
if (error_operand_p (e))
return error_mark_node;
if (NULLPTR_TYPE_P (type) && null_ptr_cst_p (e))
{
if (complain & tf_warning)
maybe_warn_zero_as_null_pointer_constant (e, loc);
if (!TREE_SIDE_EFFECTS (e))
return nullptr_node;
}
if (MAYBE_CLASS_TYPE_P (type) && (convtype & CONV_FORCE_TEMP))
/* We need a new temporary; don't take this shortcut. */;
else if (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (e)))
@ -832,12 +841,6 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
/* Ignore any integer overflow caused by the conversion. */
return ignore_overflows (converted, e);
}
if (NULLPTR_TYPE_P (type) && e && null_ptr_cst_p (e))
{
if (complain & tf_warning)
maybe_warn_zero_as_null_pointer_constant (e, loc);
return nullptr_node;
}
if (POINTER_TYPE_P (type) || TYPE_PTRMEM_P (type))
return cp_convert_to_pointer (type, e, dofold, complain);
if (code == VECTOR_TYPE)