+2007-11-23 Mark Mitchell <mark@codesourcery.com>
+ Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c++/5310
+ * call.c (convert_like_real): Build a zero constant when __null is
+ converted to an integer type.
+
2007-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34094
about to bind it to a reference, in which case we need to
leave it as an lvalue. */
if (inner >= 0)
- expr = decl_constant_value (expr);
+ {
+ expr = decl_constant_value (expr);
+ if (expr == null_node && INTEGRAL_TYPE_P (totype))
+ /* If __null has been converted to an integer type, we do not
+ want 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:
/* Call build_user_type_conversion again for the error. */
+2007-11-23 Mark Mitchell <mark@codesourcery.com>
+ Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c++/5310
+ * g++.dg/warn/pr5310.C: New.
+ * g++.dg/warn/pr33160.C: New.
+
2007-11-23 Richard Guenther <rguenther@suse.de>
Michael Matz <matz@suse.de>
--- /dev/null
+// PR 33160
+// { dg-do compile }
+// { dg-options "-Wall -Wextra -Wpointer-arith -pedantic -Wconversion" }
+
+typedef int __attribute__((mode(pointer))) intptr_t;
+int foo(void)
+{
+ intptr_t t = 0;
+ if (t != ((intptr_t)__null)) t = 1;
+ return 0;
+}
+
--- /dev/null
+// PR 5310
+// { dg-do compile }
+// { dg-options "-pedantic -Wall -Wextra -Wpointer-arith -Wconversion" }
+void foo (int);
+void foo (long);
+
+void bar()
+{
+ foo ((int)__null);
+ foo ((long)__null);
+}