aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Fromreide <magfr@lysator.liu.se>2010-06-05 06:52:18 +0200
committerJason Merrill <jason@gcc.gnu.org>2010-06-05 00:52:18 -0400
commit33c2474d7055ff84f60b57727b640cbaa7dd8caa (patch)
treea75627256e95c2e08ea8e6ff3a77847ccbf4c289
parent247078ec4ddf45f168329c23187f480355b43f90 (diff)
downloadgcc-33c2474d7055ff84f60b57727b640cbaa7dd8caa.zip
gcc-33c2474d7055ff84f60b57727b640cbaa7dd8caa.tar.gz
gcc-33c2474d7055ff84f60b57727b640cbaa7dd8caa.tar.bz2
cvt.c (cp_convert_to_pointer): Use null_ptr_cst_p.
* cvt.c (cp_convert_to_pointer): Use null_ptr_cst_p. * typeck.c (build_ptrmemfunc): Likewise. From-SVN: r160309
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cvt.c2
-rw-r--r--gcc/cp/typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog25
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr01.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr02.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr03.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr04.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr05.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr06.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr07.C3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr08.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr09.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr10.C4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr11.C23
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr12.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr13.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr14.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr15.C3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr16.C3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr17.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr18.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr20.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr21.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr22.C4
25 files changed, 132 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b051079..9c4ad0a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-04 Magnus Fromreide <magfr@lysator.liu.se>
+
+ * cvt.c (cp_convert_to_pointer): Use null_ptr_cst_p.
+ * typeck.c (build_ptrmemfunc): Likewise.
+
2010-06-04 Jason Merrill <jason@redhat.com>
* typeck2.c (merge_exception_specifiers): Adjust merging of
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 71315b1..4aee151 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -196,7 +196,7 @@ cp_convert_to_pointer (tree type, tree expr)
return error_mark_node;
}
- if (integer_zerop (expr))
+ if (null_ptr_cst_p (expr))
{
if (TYPE_PTRMEMFUNC_P (type))
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0,
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 26ffe1c..53e84cf 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7039,7 +7039,7 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p)
}
/* Handle null pointer to member function conversions. */
- if (integer_zerop (pfn))
+ if (null_ptr_cst_p (pfn))
{
pfn = build_c_cast (input_location, type, integer_zero_node);
return build_ptrmemfunc1 (to_type,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0998820..accf2e3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,28 @@
+2010-06-04 Magnus Fromreide <magfr@lysator.liu.se>
+
+ * g++.dg/cpp0x/nullptr01.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr02.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr03.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr04.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr05.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr06.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr07.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr08.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr09.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr10.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr11.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr12.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr13.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr14.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr15.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr16.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr17.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr18.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr19.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr20.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr21.C: Test nullptr_t variable.
+ * g++.dg/cpp0x/nullptr22.C: Test nullptr_t variable.
+
2010-06-04 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/noexcept06.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr01.C b/gcc/testsuite/g++.dg/cpp0x/nullptr01.C
index 8de877b..de3860c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr01.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr01.C
@@ -6,3 +6,5 @@
char* const cp1 = nullptr;
char* const cp2 = __null;
char* const cp3 = 0;
+decltype(nullptr) mynull = 0;
+char* const cp4 = mynull;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr02.C b/gcc/testsuite/g++.dg/cpp0x/nullptr02.C
index 2272152..80977cb 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr02.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr02.C
@@ -8,3 +8,9 @@ typedef decltype(nullptr) nullptr_t;
const nullptr_t np1 = nullptr;
const nullptr_t np2 = __null;
const nullptr_t np3 = 0;
+const nullptr_t np4 = np1;
+const nullptr_t np5 = np2;
+const nullptr_t np6 = np3;
+const nullptr_t np7 = np4;
+const nullptr_t np8 = np5;
+const nullptr_t np9 = np6;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr03.C b/gcc/testsuite/g++.dg/cpp0x/nullptr03.C
index 1c9e521..b6df896 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr03.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr03.C
@@ -3,4 +3,7 @@
// Test assignment to int
-const int n = nullptr; // { dg-error "cannot convert " }
+const int n1 = nullptr; // { dg-error "cannot convert " }
+decltype(nullptr) mynull = 0;
+const int n2 = mynull; // { dg-error "cannot convert " }
+
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr04.C b/gcc/testsuite/g++.dg/cpp0x/nullptr04.C
index 28e3715..6e1d125 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr04.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr04.C
@@ -11,3 +11,9 @@ const int n4 = static_cast<const int>(nullptr); // { dg-error "invalid static_ca
const short int n5 = reinterpret_cast<short int>(nullptr); // { dg-error "loses precision" }
const ssize_t n6 = reinterpret_cast<ssize_t>(nullptr);
const ssize_t n7 = (ssize_t)nullptr;
+
+decltype(nullptr) mynull = 0;
+const int n8 = static_cast<const int>(mynull); // { dg-error "invalid static_cast " }
+const short int n9 = reinterpret_cast<short int>(mynull); // { dg-error "loses precision" }
+const ssize_t n10 = reinterpret_cast<ssize_t>(mynull);
+const ssize_t n11 = (ssize_t)mynull;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr05.C b/gcc/testsuite/g++.dg/cpp0x/nullptr05.C
index 7c3f8b70..22a8b51 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr05.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr05.C
@@ -10,3 +10,5 @@ typedef void (F::*pmf)();
const pmf pmf1 = nullptr;
const pmf pmf2 = __null;
const pmf pmf3 = 0;
+decltype(nullptr) mynull = 0;
+const pmf pmf4 = mynull;
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr06.C b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C
index 5dea1fb..c50bb9b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr06.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C
@@ -10,4 +10,6 @@ char* const cp1 = nullptr;
void fun()
{
assert_true(cp1 == nullptr);
+ decltype(nullptr) mynull = 0;
+ assert_true(cp1 == mynull);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr07.C b/gcc/testsuite/g++.dg/cpp0x/nullptr07.C
index cebed88..64d442b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr07.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr07.C
@@ -9,4 +9,7 @@ void fun()
if( n == nullptr ); // { dg-error "invalid operands of types " }
const int m = 1;
if( m == nullptr ); // { dg-error "invalid operands of types " }
+ decltype(nullptr) mynull = 0;
+ if( n == mynull ); // { dg-error "invalid operands of types " }
+ if( m == mynull ); // { dg-error "invalid operands of types " }
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr08.C b/gcc/testsuite/g++.dg/cpp0x/nullptr08.C
index d7d9169..1e5db27 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr08.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr08.C
@@ -8,4 +8,6 @@
void fun()
{
assert_true(nullptr ? false : true);
+ decltype(nullptr) mynull = 0;
+ assert_true(mynull ? false : true);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr09.C b/gcc/testsuite/g++.dg/cpp0x/nullptr09.C
index a42821c..b35a3c3 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr09.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr09.C
@@ -6,4 +6,6 @@
void fun()
{
if( nullptr == 0 );
+ decltype(nullptr) mynull = 0;
+ if( mynull == 0 );
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr10.C b/gcc/testsuite/g++.dg/cpp0x/nullptr10.C
index cd13186..fa32267 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr10.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr10.C
@@ -7,4 +7,8 @@ void fun()
{
nullptr = 0; // { dg-error "lvalue required as left operand" }
nullptr + 2; // { dg-error "invalid operands of types " }
+ decltype(nullptr) mynull = 0;
+ mynull = 1; // { dg-error "cannot convert" }
+ mynull = 0;
+ mynull + 2; // { dg-error "invalid operands of types " }
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr11.C b/gcc/testsuite/g++.dg/cpp0x/nullptr11.C
index 85402a1..5907816 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr11.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr11.C
@@ -14,4 +14,27 @@ void fun()
assert_false(nullptr > nullptr);
assert_true(nullptr <= nullptr);
assert_true(nullptr >= nullptr);
+
+ decltype(nullptr) mynull = 0;
+
+ assert_true(mynull == nullptr);
+ assert_false(mynull != nullptr);
+ assert_false(mynull < nullptr);
+ assert_false(mynull > nullptr);
+ assert_true(mynull <= nullptr);
+ assert_true(mynull >= nullptr);
+
+ assert_true(nullptr == mynull);
+ assert_false(nullptr != mynull);
+ assert_false(nullptr < mynull);
+ assert_false(nullptr > mynull);
+ assert_true(nullptr <= mynull);
+ assert_true(nullptr >= mynull);
+
+ assert_true(mynull == mynull);
+ assert_false(mynull != mynull);
+ assert_false(mynull < mynull);
+ assert_false(mynull > mynull);
+ assert_true(mynull <= mynull);
+ assert_true(mynull >= mynull);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr12.C b/gcc/testsuite/g++.dg/cpp0x/nullptr12.C
index f68652c..1713259 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr12.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr12.C
@@ -4,3 +4,5 @@
// Test sizeof
static_assert(sizeof(nullptr) == sizeof(void*), "sizeof(nullptr) is wrong");
+const decltype(nullptr) mynull = 0;
+static_assert(sizeof(mynull) == sizeof(void*), "sizeof(nullptr) is wrong");
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr13.C b/gcc/testsuite/g++.dg/cpp0x/nullptr13.C
index 633e971..a937758 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr13.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr13.C
@@ -5,7 +5,12 @@
#include <typeinfo>
+#define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0)
+
void fun()
{
typeid(nullptr);
+ const decltype(nullptr) mynull = 0;
+ typeid(mynull);
+ assert_true(typeid(nullptr) == typeid(mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr14.C b/gcc/testsuite/g++.dg/cpp0x/nullptr14.C
index 0493bcc..4c4627b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr14.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr14.C
@@ -20,4 +20,6 @@ void test_f()
//
type_equal<char*>(f(nullptr));
type_equal<int>(f(0));
+ decltype(nullptr) mynull = 0;
+ type_equal<char*>(f(mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr15.C b/gcc/testsuite/g++.dg/cpp0x/nullptr15.C
index abb45f4..67d9d4a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr15.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr15.C
@@ -18,4 +18,7 @@ void test_g()
//
g(nullptr); // { dg-error "no matching function for call to " }
type_equal<float*>(g((float*)nullptr));
+ decltype(nullptr) mynull = 0;
+ g(mynull); // { dg-error "no matching function for call to " }
+ type_equal<float*>(g((float*)mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr16.C b/gcc/testsuite/g++.dg/cpp0x/nullptr16.C
index 7561b21..0ec0b6a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr16.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr16.C
@@ -19,4 +19,7 @@ void test_h()
type_equal<int>(h(0));
type_equal<nullptr_t>(h(nullptr));
type_equal<float*>(h((float*)nullptr));
+ nullptr_t mynull = 0;
+ type_equal<nullptr_t>(h(mynull));
+ type_equal<float*>(h((float*)mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr17.C b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C
index acedbae..2e58055 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr17.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C
@@ -18,4 +18,6 @@ void test_i()
{
// Overload to bool, not int
type_equal<bool>(i(nullptr));
+ decltype(nullptr) mynull = 0;
+ type_equal<bool>(i(mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr18.C b/gcc/testsuite/g++.dg/cpp0x/nullptr18.C
index 192b646..b8fa38c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr18.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr18.C
@@ -16,4 +16,6 @@ bool j( bool );
void test_j()
{
type_equal<char*>(j(nullptr));
+ decltype(nullptr) mynull = 0;
+ type_equal<char*>(j(mynull));
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr20.C b/gcc/testsuite/g++.dg/cpp0x/nullptr20.C
index a959b00..3e58406 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr20.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr20.C
@@ -10,8 +10,11 @@ int main()
{
char buf1[64];
char buf2[64];
+ char buf3[64];
std::sprintf(buf1, "%p", (void*)0);
std::sprintf(buf2, "%p", nullptr);
- return std::strcmp(buf1, buf2) != 0;
+ decltype(nullptr) mynull = 0;
+ std::sprintf(buf3, "%p", nullptr);
+ return std::strcmp(buf1, buf2) != 0 || std::strcmp(buf1, buf3) != 0;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr21.C b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C
index 84c34dd..c30cb3c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr21.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C
@@ -24,4 +24,21 @@ int main()
} catch (...) {
printf("Test 1 Fail");
} // { dg-output "Test 1 OK" }
+
+ nullptr_t mynull = 0;
+ try {
+ throw mynull;
+ } catch (void*) {
+ printf("Test 2 Fail");
+ } catch (bool) {
+ printf("Test 2 Fail");
+ } catch (int) {
+ printf("Test 2 Fail");
+ } catch (long int) {
+ printf("Test 2 Fail");
+ } catch (nullptr_t) {
+ printf("Test 2 OK");
+ } catch (...) {
+ printf("Test 2 Fail");
+ } // { dg-output "Test 2 OK" }
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr22.C b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
index 13cb8e3..d800f98 100644
--- a/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C
@@ -13,4 +13,8 @@ void f()
f2(nullptr); // { dg-warning "null argument where non-null required " }
f3("x", "y", __null); // { dg-warning "missing sentinel in function call" }
f3("x", "y", nullptr);
+ decltype(nullptr) mynull = 0;
+ f1("%p", mynull);
+ f2(mynull); // { dg-warning "null argument where non-null required " }
+ f3("x", "y", mynull);
}