Commit f61af651 by Paolo Carlini Committed by Paolo Carlini

cvt.c (cp_convert_to_pointer): Call build_ptrmemfunc before…

cvt.c (cp_convert_to_pointer): Call build_ptrmemfunc before maybe_warn_zero_as_null_pointer_constant to avoid...

2013-11-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* cvt.c (cp_convert_to_pointer): Call build_ptrmemfunc before
	maybe_warn_zero_as_null_pointer_constant to avoid duplicate
	-Wzero-as-null-pointer-constant diagnostics.

	* typeck.c (build_ptrmemfunc): Use cp_build_c_cast.

From-SVN: r204655
parent c20fdb91
2013-11-10 Paolo Carlini <paolo.carlini@oracle.com>
* cvt.c (cp_convert_to_pointer): Call build_ptrmemfunc before
maybe_warn_zero_as_null_pointer_constant to avoid duplicate
-Wzero-as-null-pointer-constant diagnostics.
* typeck.c (build_ptrmemfunc): Use cp_build_c_cast.
2013-11-06 Paolo Carlini <paolo.carlini@oracle.com> 2013-11-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/11006 PR c++/11006
......
...@@ -203,13 +203,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain) ...@@ -203,13 +203,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain)
if (null_ptr_cst_p (expr)) if (null_ptr_cst_p (expr))
{ {
if (complain & tf_warning)
maybe_warn_zero_as_null_pointer_constant (expr, loc);
if (TYPE_PTRMEMFUNC_P (type)) if (TYPE_PTRMEMFUNC_P (type))
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0, return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
/*c_cast_p=*/false, complain); /*c_cast_p=*/false, complain);
if (complain & tf_warning)
maybe_warn_zero_as_null_pointer_constant (expr, loc);
/* A NULL pointer-to-data-member is represented by -1, not by /* A NULL pointer-to-data-member is represented by -1, not by
zero. */ zero. */
tree val = (TYPE_PTRDATAMEM_P (type) tree val = (TYPE_PTRDATAMEM_P (type)
......
...@@ -7779,7 +7779,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p, ...@@ -7779,7 +7779,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
/* Handle null pointer to member function conversions. */ /* Handle null pointer to member function conversions. */
if (null_ptr_cst_p (pfn)) if (null_ptr_cst_p (pfn))
{ {
pfn = build_c_cast (input_location, type, pfn); pfn = cp_build_c_cast (type, pfn, complain);
return build_ptrmemfunc1 (to_type, return build_ptrmemfunc1 (to_type,
integer_zero_node, integer_zero_node,
pfn); pfn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment