From: Patrick Palka Date: Fri, 6 Mar 2020 18:19:13 +0000 (-0500) Subject: c++: Fix pretty printing of TYPENAME_TYPEs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff0a62841e27b838f17a9d6253d131206072df6f;p=gcc.git c++: Fix pretty printing of TYPENAME_TYPEs I noticed that in some concepts diagnostic messages, we were printing typename types incorrectly, e.g. printing remove_reference_t as typename remove_reference::remove_reference_t instead of typename remove_reference::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. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 98640a671cc..48ef75c732e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-08 Patrick Palka + + * 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 PR c++/94027 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/ChangeLog b/gcc/testsuite/ChangeLog index 6fa77ce5505..99e2e426010 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-03-08 Patrick Palka + + * g++.dg/concepts/diagnostic4.C: New test. + 2020-03-08 H.J. Lu 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 index 00000000000..677bc867634 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/diagnostic4.C @@ -0,0 +1,18 @@ +// { dg-do compile { target c++2a } } + +template + struct remove_reference + { using type = T; }; + +template + using remove_reference_t = remove_reference::type; + +template + inline constexpr bool blah = false; + +template + requires blah> + // { dg-message "typename remove_reference::type" "" { target *-*-* } .-1 } + void foo() { } + +void bar() { foo (); } // { dg-error "use of" }