From 2ad2e0afc6e7c7510c340b8de6202ed1f3f9b733 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 26 Nov 2014 20:11:16 +0000 Subject: [PATCH] re PR c++/63757 (nullptr conversion sequence fails to compile) /cp 2014-11-26 Paolo Carlini PR c++/63757 * call.c (standard_conversion): Do not require expr to be non-null when NULLPTR_TYPE_P (from) is true. /testsuite 2014-11-26 Paolo Carlini PR c++/63757 * g++.dg/cpp0x/nullptr33.C: New. From-SVN: r218098 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/nullptr33.C | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nullptr33.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 32092c418a1..756c8d8b5d1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-11-26 Paolo Carlini + + PR c++/63757 + * call.c (standard_conversion): Do not require expr to be non-null + when NULLPTR_TYPE_P (from) is true. + 2014-11-26 Jason Merrill * constexpr.c (cxx_eval_constant_expression) [SAVE_EXPR]: Avoid diff --git a/gcc/cp/call.c b/gcc/cp/call.c index a7a8667b5f8..d8075bd97ea 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1194,7 +1194,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, rvalue of type std::nullptr_t. */ if ((tcode == POINTER_TYPE || TYPE_PTRMEM_P (to) || NULLPTR_TYPE_P (to)) - && expr && null_ptr_cst_p (expr)) + && ((expr && null_ptr_cst_p (expr)) + || NULLPTR_TYPE_P (from))) conv = build_conv (ck_std, to, conv); else if ((tcode == INTEGER_TYPE && fcode == POINTER_TYPE) || (tcode == POINTER_TYPE && fcode == INTEGER_TYPE)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b8239da9148..d32f1f99b76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-26 Paolo Carlini + + PR c++/63757 + * g++.dg/cpp0x/nullptr33.C: New. + 2014-11-26 Jakub Jelinek * lib/tsan-dg.exp (check_effective_target_fsanitize_thread, diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr33.C b/gcc/testsuite/g++.dg/cpp0x/nullptr33.C new file mode 100644 index 00000000000..75c782ac8ff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr33.C @@ -0,0 +1,19 @@ +// PR c++/63757 +// { dg-do compile { target c++11 } } + +typedef decltype(nullptr) nullptr_t; + +void bar(void*) {} + +struct foo +{ + operator nullptr_t() + { + return nullptr; + } +}; + +int main() +{ + bar(foo()); +} -- 2.30.2