]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix pretty printing of TYPENAME_TYPEs
authorPatrick Palka <ppalka@redhat.com>
Fri, 6 Mar 2020 18:19:13 +0000 (13:19 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sun, 8 Mar 2020 14:45:14 +0000 (10:45 -0400)
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.

Fix this by printing the TYPENAME_TYPE_FULLNAME instead of the TYPE_NAME in
cxx_pretty_printer::simple_type_specifier, which is consistent with how
dump_typename in error.c does it.

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/ChangeLog
gcc/cp/cxx-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/concepts/diagnostic4.C [new file with mode: 0644]

index 98640a671cc570a1b70751df7f8e64a55ca86eb5..48ef75c732e3d3e49137f8b8dd0aa74bc90ce785 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-08  Patrick Palka  <ppalka@redhat.com>
+
+       * cxx-pretty-print.c (cxx_pretty_printer::simple_type_specifier)
+       [TYPENAME_TYPE]: Print the TYPENAME_TYPE_FULLNAME instead of the
+       TYPE_NAME.
+
 2020-03-06  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/94027
index 397bdbfa2346f9f49477f013142c22866d201530..100154e400f61e2ac59de182b26c1e079ae3dfc8 100644 (file)
@@ -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:
index 6fa77ce5505cb5e2e816cb40cb44331b8f9e5ec2..99e2e4260109bca201e71a5630528e5ac27d74e5 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-08  Patrick Palka  <ppalka@redhat.com>
+
+       * g++.dg/concepts/diagnostic4.C: New test.
+
 2020-03-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/89229
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic4.C b/gcc/testsuite/g++.dg/concepts/diagnostic4.C
new file mode 100644 (file)
index 0000000..677bc86
--- /dev/null
@@ -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" }