On 3/6/20 1:41 PM, Patrick Palka wrote:
I noticed that in some concepts diagnostic messages, we were printing typename
types incorrectly, e.g. printing remove_reference_t<T> as

   typename remove_reference<T>::remove_reference_t

instead of

   typename remove_reference<T>::type.

Fixed this by looking at TYPENAME_TYPE_FULLNAME instead of TYPE_NAME, which is
consistent with how dump_typename in error.c does it.

Does this look OK to commit after testing?

OK.

gcc/cp/ChangeLog:

        * cxx-pretty-print.c (cxx_pretty_printer::simple_type_specifier)
        [TYPENAME_TYPE]: Print the TYPENAME_TYPE_FULLNAME instead of the
        TYPE_NAME.

gcc/testsuite/ChangeLog:

        * g++.dg/concepts/diagnostic4.C: New test.
---
  gcc/cp/cxx-pretty-print.c                   |  2 +-
  gcc/testsuite/g++.dg/concepts/diagnostic4.C | 18 ++++++++++++++++++
  2 files changed, 19 insertions(+), 1 deletion(-)
  create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic4.C

diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 397bdbfa234..100154e400f 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -1360,7 +1360,7 @@ cxx_pretty_printer::simple_type_specifier (tree t)
      case TYPENAME_TYPE:
        pp_cxx_ws_string (this, "typename");
        pp_cxx_nested_name_specifier (this, TYPE_CONTEXT (t));
-      pp_cxx_unqualified_id (this, TYPE_NAME (t));
+      pp_cxx_unqualified_id (this, TYPENAME_TYPE_FULLNAME (t));
        break;
default:
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic4.C 
b/gcc/testsuite/g++.dg/concepts/diagnostic4.C
new file mode 100644
index 00000000000..677bc867634
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic4.C
@@ -0,0 +1,18 @@
+// { dg-do compile { target c++2a } }
+
+template<typename T>
+  struct remove_reference
+  { using type = T; };
+
+template<typename T>
+  using remove_reference_t = remove_reference<T>::type;
+
+template<typename T>
+  inline constexpr bool blah = false;
+
+template<typename T>
+  requires blah<remove_reference_t<T>>
+  // { dg-message "typename remove_reference<T>::type" "" { target *-*-* } .-1 
}
+  void foo() { }
+
+void bar() { foo<int> (); } // { dg-error "use of" }


Reply via email to