From 39d8c7d2c1104ee8e9e19dec0c3a4973805fdb9e Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 5 May 2018 07:39:36 +0000 Subject: cvt.c (ocp_convert): Early handle the special case of a null_ptr_cst_p expr converted to a... 2018-05-05 Paolo Carlini * 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/cvt.c | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6ae6707..f7969d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-05-05 Paolo Carlini + + * 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 PR c++/85600 - virtual delete failure. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index d9e3cb5..9494f29 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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) -- cgit v1.1