diff mbox

C++ PATCH for c++/81671, nullptr_t template parameter

Message ID CADzB+2k_NC=KZ3nKazzJ8qUrMSpKr3_b+DVDGsGUevGepGOKvw@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill Aug. 11, 2017, 5:35 a.m. UTC
We were wrongly checking for nullptr_node rather than nullptr_type.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 325d154928a702116006f1ca40806cee600d6a8b
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 10 22:05:38 2017 -0700

            PR c++/81671 - nullptr_t template parameter
    
            * pt.c (convert_nontype_argument): Fix nullptr_t check.
diff mbox

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0f899b9..bf1f75d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6879,7 +6879,7 @@  convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
     }
   else if (NULLPTR_TYPE_P (type))
     {
-      if (expr != nullptr_node)
+      if (!NULLPTR_TYPE_P (TREE_TYPE (expr)))
 	{
 	  if (complain & tf_error)
 	    error ("%qE is not a valid template argument for type %qT "
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr39.C b/gcc/testsuite/g++.dg/cpp0x/nullptr39.C
new file mode 100644
index 0000000..a34a6af
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr39.C
@@ -0,0 +1,15 @@ 
+// PR c++/81671
+// { dg-do compile { target c++11 } }
+
+namespace std { typedef decltype(nullptr) nullptr_t; }
+
+template<class R, class CB> struct Bar
+{};
+template<class R> struct Bar<R, std::nullptr_t>
+{
+    template<std::nullptr_t> struct Bind { constexpr static int const cb = 0; };
+};
+int foo()
+{
+  return Bar<int, decltype(nullptr)>::Bind<nullptr>::cb;
+}