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
This commit is contained in:
Paolo Carlini 2013-11-10 23:40:57 +00:00 committed by Paolo Carlini
parent c20fdb917f
commit f61af651e2
3 changed files with 12 additions and 4 deletions

View file

@ -1,3 +1,11 @@
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>
PR c++/11006

View file

@ -203,13 +203,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubst_flags_t complain)
if (null_ptr_cst_p (expr))
{
if (complain & tf_warning)
maybe_warn_zero_as_null_pointer_constant (expr, loc);
if (TYPE_PTRMEMFUNC_P (type))
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
/*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
zero. */
tree val = (TYPE_PTRDATAMEM_P (type)

View file

@ -7779,7 +7779,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
/* Handle null pointer to member function conversions. */
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,
integer_zero_node,
pfn);