Commit 4b91b67b by Roger Sayle Committed by Roger Sayle

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
parent 06a103af
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
......
......@@ -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;
}
......
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.
/* 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" }
/* 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" }
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