Hi,

in private email, Daniel pointed out that, post my recent fix in this area, instantiation is not handled yet. Thus I prepared the very simple patch below. Should we provide a more specific error message?

Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
/cp
2011-09-26  Paolo Carlini  <paolo.carl...@oracle.com>

        * pt.c (convert_nontype_argument): Handle NULLPTR_TYPE.

/testsuite
2011-09-26  Paolo Carlini  <paolo.carl...@oracle.com>

        * g++.dg/cpp0x/nullptr25.C: New.
Index: testsuite/g++.dg/cpp0x/nullptr25.C
===================================================================
--- testsuite/g++.dg/cpp0x/nullptr25.C  (revision 0)
+++ testsuite/g++.dg/cpp0x/nullptr25.C  (revision 0)
@@ -0,0 +1,6 @@
+// { dg-options -std=c++0x }
+
+template<decltype(nullptr)>
+struct nt{};
+
+nt<nullptr> x;
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 179187)
+++ cp/pt.c     (working copy)
@@ -5951,6 +5951,16 @@ convert_nontype_argument (tree type, tree expr, ts
       if (expr == error_mark_node)
        return expr;
     }
+  else if (NULLPTR_TYPE_P (type))
+    {
+      if (expr != nullptr_node)
+       {
+         error ("%qE is not a valid template argument for type %qT "
+                "because it is of type %qT", expr, type, TREE_TYPE (expr));
+         return NULL_TREE;
+       }
+      return expr;
+    }
   /* A template non-type parameter must be one of the above.  */
   else
     gcc_unreachable ();

Reply via email to