t = OVL_FIRST (t);
/* FALLTHRU */
case VAR_DECL:
+ if (DECL_NTTP_OBJECT_P (t))
+ {
+ /* Print the type followed by the CONSTRUCTOR value of the
+ NTTP object. */
+ simple_type_specifier (cv_unqualified (TREE_TYPE (t)));
+ expression (DECL_INITIAL (t));
+ break;
+ }
+ /* FALLTHRU */
case PARM_DECL:
case FIELD_DECL:
case CONST_DECL:
pp_cxx_right_paren (this);
break;
+ case VIEW_CONVERT_EXPR:
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == TEMPLATE_PARM_INDEX)
+ {
+ /* Strip const VIEW_CONVERT_EXPR wrappers for class NTTPs. */
+ expression (TREE_OPERAND (t, 0));
+ break;
+ }
+ /* FALLTHRU */
default:
c_pretty_printer::expression (t);
break;
if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
&& TYPE_P (DECL_TEMPLATE_RESULT (arg))))
pp->type_id (arg);
- else if (VAR_P (arg) && DECL_NTTP_OBJECT_P (arg))
- pp->expression (DECL_INITIAL (arg));
else
pp->expression (arg);
}
--- /dev/null
+// Verify pretty printing of class NTTP objects.
+// PR c++/111471
+// { dg-do compile { target c++20 } }
+
+struct A { bool value; };
+
+template<A V>
+ requires (V.value) // { dg-message {'\(V\).value \[with V = A\{false\}\]'} }
+void f();
+
+template<A V> struct B { static constexpr auto value = V.value; };
+
+template<class T>
+ requires T::value // { dg-message {'T::value \[with T = B<A\{false\}>\]'} }
+void g();
+
+int main() {
+ f<A{false}>(); // { dg-error "no match" }
+ g<B<A{false}>>(); // { dg-error "no match" }
+}