diff mbox

[C++] Fix for ICE when instantiating non-type template with nullptr

Message ID 4E8067C8.1070206@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Sept. 26, 2011, 11:53 a.m. UTC
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.carlini@oracle.com>

	* pt.c (convert_nontype_argument): Handle NULLPTR_TYPE.

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

	* g++.dg/cpp0x/nullptr25.C: New.

Comments

Jason Merrill Sept. 26, 2011, 1:29 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

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 ();