* [C++ Patch] Fixes for duplicate warnings regressions [2/2]
@ 2013-11-10 11:49 Paolo Carlini
2013-11-10 20:04 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2013-11-10 11:49 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 486 bytes --]
Hi,
this is another issue, with -Wzero-as-null-pointer-constant, caused (or,
better, exposed) by the fix for c++/54170: the problem is that
build_ptrmemfunc, called by cp_convert_to_pointer, itself eventually
calls cp_convert_to_pointer.
The build_ptrmemfunc bit isn't essential: using the cp_* variant of
build_c_cast, which takes a tsubst_flags_t, in a function taking a
tsubst_flags_t seems the right thing to do.
Tested x86_64-linux.
Thanks!
Paolo.
//////////////////////
[-- Attachment #2: CL_du_2 --]
[-- Type: text/plain, Size: 279 bytes --]
2013-11-11 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.
[-- Attachment #3: patch_du_2 --]
[-- Type: text/plain, Size: 1215 bytes --]
Index: cp/cvt.c
===================================================================
--- cp/cvt.c (revision 204620)
+++ cp/cvt.c (working copy)
@@ -203,13 +203,13 @@ cp_convert_to_pointer (tree type, tree expr, tsubs
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)
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 204620)
+++ cp/typeck.c (working copy)
@@ -7779,7 +7781,7 @@ build_ptrmemfunc (tree type, tree pfn, int force,
/* 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ Patch] Fixes for duplicate warnings regressions [2/2]
2013-11-10 11:49 [C++ Patch] Fixes for duplicate warnings regressions [2/2] Paolo Carlini
@ 2013-11-10 20:04 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2013-11-10 20:04 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-10 18:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-10 11:49 [C++ Patch] Fixes for duplicate warnings regressions [2/2] Paolo Carlini
2013-11-10 20:04 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).