diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2015-08-17 21:40:07 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-08-17 21:40:07 +0000 |
commit | 5916cfd01b73646934abf404de8528c11b842070 (patch) | |
tree | ac9bf378b710ec8c5ec4243d11b1ff0baf82d0de /gcc/cp | |
parent | b361a15ff60daf83fc2ddccbc6166e4bd19e2b35 (diff) | |
download | gcc-5916cfd01b73646934abf404de8528c11b842070.zip gcc-5916cfd01b73646934abf404de8528c11b842070.tar.gz gcc-5916cfd01b73646934abf404de8528c11b842070.tar.bz2 |
re PR c++/67216 (false is still a null pointer constant)
/cp
2015-08-17 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67216
* call.c (null_ptr_cst_p): In C++11 return 'false' for 'false'.
/testsuite
2015-08-17 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/67216
* g++.dg/cpp0x/nullptr34.C: New.
* g++.dg/warn/Wconversion2.C: Adjust.
* g++.dg/warn/Wnull-conversion-1.C: Likewise.
* g++.old-deja/g++.other/null3.C: Likewise.
* g++.dg/cpp0x/pr51313.C: Adjust.
From-SVN: r226956
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/call.c | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca00d03..0bf33c8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-08-17 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/67216 + * call.c (null_ptr_cst_p): In C++11 return 'false' for 'false'. + 2015-08-17 Jason Merrill <jason@redhat.com> PR c++/67244 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 19ddb91..909ac99 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -524,22 +524,33 @@ struct z_candidate { bool null_ptr_cst_p (tree t) { + tree type = TREE_TYPE (t); + /* [conv.ptr] A null pointer constant is an integral constant expression (_expr.const_) rvalue of integer type that evaluates to zero or an rvalue of type std::nullptr_t. */ - if (NULLPTR_TYPE_P (TREE_TYPE (t))) + if (NULLPTR_TYPE_P (type)) return true; - if (CP_INTEGRAL_TYPE_P (TREE_TYPE (t))) + + if (cxx_dialect >= cxx11) { /* Core issue 903 says only literal 0 is a null pointer constant. */ - if (cxx_dialect < cxx11) - t = fold_non_dependent_expr (t); + if (TREE_CODE (type) == INTEGER_TYPE + && TREE_CODE (t) == INTEGER_CST + && integer_zerop (t) + && !TREE_OVERFLOW (t)) + return true; + } + else if (CP_INTEGRAL_TYPE_P (type)) + { + t = fold_non_dependent_expr (t); STRIP_NOPS (t); if (integer_zerop (t) && !TREE_OVERFLOW (t)) return true; } + return false; } |