re PR c++/63757 (nullptr conversion sequence fails to compile)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 26 Nov 2014 20:11:16 +0000 (20:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 26 Nov 2014 20:11:16 +0000 (20:11 +0000)
/cp
2014-11-26  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/63757
* g++.dg/cpp0x/nullptr33.C: New.

From-SVN: r218098

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nullptr33.C [new file with mode: 0644]

index 32092c418a15e10de09fef03e9b09e5525cef2f3..756c8d8b5d1ac30ad48d710f5febbd1f14b4f9e3 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jason@redhat.com>
 
        * constexpr.c (cxx_eval_constant_expression) [SAVE_EXPR]: Avoid
index a7a8667b5f8953d32db3754e8683b1b6ec669777..d8075bd97ea72d15466d7da3a86501da9d3761a4 100644 (file)
@@ -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))
index b8239da914864e347c13b2435f51772571c558a4..d32f1f99b766704ab54ffa3efdd7cef8ca5bfad5 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/63757
+       * g++.dg/cpp0x/nullptr33.C: New.
+
 2014-11-26  Jakub Jelinek  <jakub@redhat.com>
 
        * 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 (file)
index 0000000..75c782a
--- /dev/null
@@ -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());
+}