On Fri, Dec 20, 2024 at 12:51:02PM -0500, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > -- >8 -- > Compiling this test, we emit: > > error: 'static void CW<T>::operator=(int) requires > requires(typename'decltype_type' not supported by pp_cxx_unqualified_id::type > x) {x;}' must be a non-static member function > > where the DECLTYPE_TYPE isn't printed properly. This patch fixes that > to print: > > error: 'static void CW<T>::operator=(int) requires requires(typename > decltype(T())::type x) {x;}' must be a non-static member function > > PR c++/118139 > > gcc/cp/ChangeLog: > > * cxx-pretty-print.cc (pp_cxx_nested_name_specifier): Handle > a computed-type-specifier. > > gcc/testsuite/ChangeLog: > > * g++.dg/diagnostic/decltype1.C: New test. > --- > gcc/cp/cxx-pretty-print.cc | 14 +++++++++++--- > gcc/testsuite/g++.dg/diagnostic/decltype1.C | 8 ++++++++ > 2 files changed, 19 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/diagnostic/decltype1.C > > diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc > index 4104c6863c7..caa74e3b86f 100644 > --- a/gcc/cp/cxx-pretty-print.cc > +++ b/gcc/cp/cxx-pretty-print.cc > @@ -234,8 +234,12 @@ pp_cxx_template_keyword_if_needed (cxx_pretty_printer > *pp, tree scope, tree t) > } > > /* nested-name-specifier: > - class-or-namespace-name :: nested-name-specifier(opt) > - class-or-namespace-name :: template nested-name-specifier */ > + :: > + type-name :: > + namespace-name :: > + computed-type-specifier :: > + nested-name-specifier identifier :: > + nested-name-specifier templateopt simple-template-id :: */
Consider this line fixed to say: nested-name-specifier template(opt) simple-template-id :: (missing parens). Marek