call.c (null_ptr_cst_p): Add explicit TREE_CONSTANT_OVERFLOW check.

* call.c (null_ptr_cst_p): Add explicit TREE_CONSTANT_OVERFLOW check.

	* g++.dg/conversion/nullptr1.C: New test case.
	* g++.dg/conversion/nullptr2.C: Likewise.

From-SVN: r112734
This commit is contained in:
Roger Sayle 2006-04-06 16:47:40 +00:00 committed by Roger Sayle
parent 06a103af0e
commit 4b91b67bcb
5 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2006-04-06 Roger Sayle <roger@eyesopen.com>
* call.c (null_ptr_cst_p): Add explicit TREE_CONSTANT_OVERFLOW check.
2006-04-05 Jason Merrill <jason@redhat.com>
* name-lookup.c (push_namespace_with_attribs): Temporarily disable

View File

@ -427,7 +427,9 @@ null_ptr_cst_p (tree t)
(_expr.const_) rvalue of integer type that evaluates to zero. */
t = integral_constant_value (t);
if (t == null_node
|| (CP_INTEGRAL_TYPE_P (TREE_TYPE (t)) && integer_zerop (t)))
|| (CP_INTEGRAL_TYPE_P (TREE_TYPE (t))
&& integer_zerop (t)
&& !TREE_CONSTANT_OVERFLOW (t)))
return true;
return false;
}

View File

@ -1,3 +1,8 @@
2006-04-06 Roger Sayle <roger@eyesopen.com>
* g++.dg/conversion/nullptr1.C: New test case.
* g++.dg/conversion/nullptr2.C: Likewise.
2006-04-05 Roger Sayle <roger@eyesopen.com>
* gfortran.dg/dependency_18.f90: New test case.

View File

@ -0,0 +1,10 @@
/* Test for overflow in NULL pointer constant. */
/* { dg-do compile } */
#include <limits.h>
void *p = 0;
void *q = 0 * (INT_MAX + 1); // { dg-error "invalid conversion" }

View File

@ -0,0 +1,10 @@
/* Test for enumeration as NULL pointer constant. */
/* PR c++/14644 */
/* { dg-do compile } */
enum { NULL = 0 };
void *p = 0;
void *q = NULL; // { dg-error "cannot convert" }