diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-05-05 07:39:36 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-05-05 07:39:36 +0000 |
commit | 39d8c7d2c1104ee8e9e19dec0c3a4973805fdb9e (patch) | |
tree | f0105f418ff20ef1d0feecb79a1a34efbc1af87f /gcc/cp | |
parent | c3f57fa1008774cd8a13d73f6747df927c32994e (diff) | |
download | gcc-39d8c7d2c1104ee8e9e19dec0c3a4973805fdb9e.zip gcc-39d8c7d2c1104ee8e9e19dec0c3a4973805fdb9e.tar.gz gcc-39d8c7d2c1104ee8e9e19dec0c3a4973805fdb9e.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | 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 <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. 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) |