case UNBOUND_CLASS_TEMPLATE:
pp_cxx_unqualified_id (pp, TYPE_NAME (t));
if (tree ti = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (t))
- {
- pp_cxx_begin_template_argument_list (pp);
- tree args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (ti));
- pp_cxx_template_argument_list (pp, args);
- pp_cxx_end_template_argument_list (pp);
- }
+ if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (ti)))
+ {
+ pp_cxx_begin_template_argument_list (pp);
+ tree args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (ti));
+ pp_cxx_template_argument_list (pp, args);
+ pp_cxx_end_template_argument_list (pp);
+ }
break;
case BIT_NOT_EXPR:
--- /dev/null
+// PR c++/95303
+// { dg-do compile { target c++20 } }
+
+template<class>
+struct A {
+ struct B {};
+};
+
+template<class T>
+ requires __is_same(T, char)
+struct A<T> {
+ struct B {};
+};
+
+template<>
+ struct A<bool> {
+ struct B {};
+ };
+
+template<class T>
+concept C = requires (T&& t) { // { dg-message "\\\[with T = A<int>::B\\\]" }
+ t.a;
+};
+static_assert(C<A<int>::B>); // { dg-error "failed" }
+
+template<class T>
+concept D = requires (T&& t) { // { dg-message "\\\[with T = A<char>::B\\\]" }
+ t.a;
+};
+static_assert(D<A<char>::B>); // { dg-error "failed" }
+
+template<class T>
+concept E = requires (T&& t) { // { dg-message "\\\[with T = A<bool>::B\\\]" }
+ t.a;
+};
+static_assert(E<A<bool>::B>); // { dg-error "failed" }