The C++ printer doesn't handle NULLPTR_TYPE, so we issue the ugly
"'nullptr_type' not supported by...". Since NULLPTR_TYPE is
decltype(nullptr), it seemed reasonable to handle it where we
handle DECLTYPE_TYPE, that is, in the simple-type-specifier handler.
gcc/cp/ChangeLog:
PR c++/97517
* cxx-pretty-print.c (cxx_pretty_printer::simple_type_specifier): Handle
NULLPTR_TYPE.
(pp_cxx_type_specifier_seq): Likewise.
(cxx_pretty_printer::type_id): Likewise.
gcc/testsuite/ChangeLog:
PR c++/97517
* g++.dg/diagnostic/nullptr.C: New test.
pp_cxx_right_paren (this);
break;
+ case NULLPTR_TYPE:
+ pp_cxx_ws_string (this, "std::nullptr_t");
+ break;
+
default:
c_pretty_printer::simple_type_specifier (t);
break;
case TYPE_DECL:
case BOUND_TEMPLATE_TEMPLATE_PARM:
case DECLTYPE_TYPE:
+ case NULLPTR_TYPE:
pp_cxx_cv_qualifier_seq (pp, t);
pp->simple_type_specifier (t);
break;
case TYPEOF_TYPE:
case UNDERLYING_TYPE:
case DECLTYPE_TYPE:
+ case NULLPTR_TYPE:
case TEMPLATE_ID_EXPR:
case OFFSET_TYPE:
pp_cxx_type_specifier_seq (this, t);
--- /dev/null
+// PR c++/97517
+// { dg-do compile { target c++20 } }
+// Test that we print "decltype(nullptr)" correctly.
+
+template<typename T> struct Trait { static constexpr bool value = false; };
+template<typename T> concept Concept = Trait<T>::value; // { dg-message {\[with T = std::nullptr_t\]} }
+static_assert( Concept<decltype(nullptr)> ); // { dg-error "static assertion failed" }
+// { dg-message "constraints not satisfied" "" { target *-*-* } .-1 }