From: Jason Merrill Date: Fri, 9 Jun 2017 20:18:06 +0000 (-0400) Subject: Fix template argument of nullptr_t type. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c5d6c6d94e74dd2f72e323ff01ad2506115ffe05;p=gcc.git Fix template argument of nullptr_t type. * pt.c (convert_nontype_argument): Check NULLPTR_TYPE_P rather than nullptr_node. From-SVN: r249080 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7bc9c204a29..8695d37850c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-06-09 Jason Merrill + * 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d8f8d467200..40be3c1d22f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..82d75ed2816 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr38.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +using nullptr_t = decltype(nullptr); + +constexpr nullptr_t n = nullptr; + +template struct A { }; + +A a;