From 27bec7bf4afb31eac4a79857ffe7aab3d9182e87 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 23 Aug 2011 12:03:25 -0400 Subject: [PATCH] Core 903 (partial) Core 903 (partial) * call.c (null_ptr_cst_p): Only 0 qualifies in C++11. From-SVN: r177996 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 14 ++++---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0f325a89367..bbada45813c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-08-23 Jason Merrill + + Core 903 (partial) + * call.c (null_ptr_cst_p): Only 0 qualifies in C++11. + 2011-08-23 Jason Merrill Core 975 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d2700cbeac8..e5f65b31c6c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -541,20 +541,14 @@ null_ptr_cst_p (tree t) return true; if (CP_INTEGRAL_TYPE_P (TREE_TYPE (t))) { - if (cxx_dialect >= cxx0x) - { - t = fold_non_dependent_expr (t); - t = maybe_constant_value (t); - if (TREE_CONSTANT (t) && integer_zerop (t)) - return true; - } - else + /* Core issue 903 says only literal 0 is a null pointer constant. */ + if (cxx_dialect < cxx0x) { t = integral_constant_value (t); STRIP_NOPS (t); - if (integer_zerop (t) && !TREE_OVERFLOW (t)) - return true; } + if (integer_zerop (t) && !TREE_OVERFLOW (t)) + return true; } return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9dfa4d3eb29..a85caca0ff5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-23 Jason Merrill + + Core 903 + * g++.dg/cpp0x/constexpr-nullptr.C: Now ill-formed. + 2011-08-23 Jason Merrill Core 975 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C index 7ac53db489c..6381323cc0c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C @@ -2,5 +2,5 @@ constexpr int zero() { return 0; } -void* ptr1 = zero(); // #1 -constexpr void* ptr2 = zero(); // #2 +void* ptr1 = zero(); // { dg-error "int" } +constexpr void* ptr2 = zero(); // { dg-error "int" } -- 2.30.2