Fix template argument of nullptr_t type.
authorJason Merrill <jason@redhat.com>
Fri, 9 Jun 2017 20:18:06 +0000 (16:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 9 Jun 2017 20:18:06 +0000 (16:18 -0400)
* pt.c (convert_nontype_argument): Check NULLPTR_TYPE_P rather than
nullptr_node.

From-SVN: r249080

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

index 7bc9c20..8695d37 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-09  Jason Merrill  <jason@redhat.com>
 
+       * pt.c (convert_nontype_argument): Check NULLPTR_TYPE_P rather than
+       nullptr_node.
+
        * parser.c (cp_parser_constant_expression): Check
        potential_rvalue_constant_expression after decay_conversion.
        * pt.c (convert_nontype_argument): Don't require linkage in C++17.
index d8f8d46..40be3c1 100644 (file)
@@ -6480,7 +6480,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
 
   /* 14.3.2/5: The null pointer{,-to-member} conversion is applied
      to a non-type argument of "nullptr".  */
-  if (expr == nullptr_node && TYPE_PTR_OR_PTRMEM_P (type))
+  if (NULLPTR_TYPE_P (expr_type) && TYPE_PTR_OR_PTRMEM_P (type))
     expr = fold_simple (convert (type, expr));
 
   /* In C++11, integral or enumeration non-type template arguments can be
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr38.C b/gcc/testsuite/g++.dg/cpp0x/nullptr38.C
new file mode 100644 (file)
index 0000000..82d75ed
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+
+using nullptr_t = decltype(nullptr);
+
+constexpr nullptr_t n = nullptr;
+
+template <void *> struct A { };
+
+A<n> a;