Commit 6ca39fcb by Mark Mitchell Committed by Manuel López-Ibáñez

re PR c++/5310 (Weird warnings about using (int)NULL)

2007-11-23  Mark Mitchell  <mark@codesourcery.com>
	    Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
	
	PR c++/5310
cp/
	* call.c (convert_like_real): Build a zero constant when __null is
	converted to an integer type.
testsuite/
	* g++.dg/warn/pr5310.C: New.
	* g++.dg/warn/pr33160.C: New

Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>

From-SVN: r130381
parent f89935ed
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
......
......@@ -4420,7 +4420,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
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>
// 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;
}
// 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);
}
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