diff mbox series

C++ PATCH for c++/81067, redundant NULL warning

Message ID CADzB+2nK8Cuz_pSWWJQo4ea19ZPBBfNH3QSB9KUgU_YvrpEUGg@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/81067, redundant NULL warning | expand

Commit Message

Jason Merrill Jan. 17, 2018, 5:07 p.m. UTC
My June 9 patch to remove the call to scalar_constant_value from
convert_like_real wrongly also removed the NULL handling that avoids
repeated warnings.  This patch restores that code.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 6d452cf34a321c16b6777c2e20a72b39fbf77a24
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 17 11:29:23 2018 -0500

            PR c++/81067 - redundant NULL warning.
    
            * call.c (convert_like_real): Restore null_node handling.
diff mbox series

Patch

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f5542850cea..1f326d5c1ad 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6804,6 +6804,12 @@  convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
 
       if (type_unknown_p (expr))
 	expr = instantiate_type (totype, expr, complain);
+      if (expr == null_node
+	  && INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (totype))
+	/* If __null has been converted to an integer type, we do not want to
+	   continue to warn about uses of EXPR as an integer, rather than as a
+	   pointer.  */
+	expr = build_int_cst (totype, 0);
       return expr;
     case ck_ambig:
       /* We leave bad_p off ck_ambig because overload resolution considers