OK.
On Tue, Aug 30, 2016 at 10:43 AM, David Malcolm <dmalc...@redhat.com> wrote: > This patch adds fix-it hints to our warning for >> > within a nested template argument list (for -std=c++98). > > For example: > > double-greater-than-fixit.C:5:12: error: ‘>>’ should be ‘> >’ within a nested > template argument list > foo<foo<int>> i; > ^~ > > > > > In conjunction with the not-yet-in-trunk -fdiagnostics-generate-patch, > this can generate patches like this: > > --- double-greater-than-fixit.C > +++ double-greater-than-fixit.C > @@ -4,3 +4,3 @@ > > -foo<foo<int>> i; > +foo<foo<int> > i; > > Successfully bootstrapped®rtested on x86_64-pc-linux-gnu. > > OK for trunk? > > gcc/cp/ChangeLog: > * parser.c (cp_parser_enclosed_template_argument_list): Add fix-it > hint to ">>" within nested template argument list error. > > gcc/testsuite/ChangeLog: > * g++.dg/template/double-greater-than-fixit.C: New test case. > --- > gcc/cp/parser.c | 6 ++++-- > gcc/testsuite/g++.dg/template/double-greater-than-fixit.C | 10 ++++++++++ > 2 files changed, 14 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/template/double-greater-than-fixit.C > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index 48dbca1..ca9f8b9 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > @@ -26342,8 +26342,10 @@ cp_parser_enclosed_template_argument_list > (cp_parser* parser) > global source location is still on the token before the > '>>', so we need to say explicitly where we want it. */ > cp_token *token = cp_lexer_peek_token (parser->lexer); > - error_at (token->location, "%<>>%> should be %<> >%> " > - "within a nested template argument list"); > + gcc_rich_location richloc (token->location); > + richloc.add_fixit_replace ("> >"); > + error_at_rich_loc (&richloc, "%<>>%> should be %<> >%> " > + "within a nested template argument list"); > > token->type = CPP_GREATER; > } > diff --git a/gcc/testsuite/g++.dg/template/double-greater-than-fixit.C > b/gcc/testsuite/g++.dg/template/double-greater-than-fixit.C > new file mode 100644 > index 0000000..f0de4ec > --- /dev/null > +++ b/gcc/testsuite/g++.dg/template/double-greater-than-fixit.C > @@ -0,0 +1,10 @@ > +/* { dg-options "-fdiagnostics-show-caret -std=c++98" } */ > +template <typename T> > +struct foo {}; > + > +foo<foo<int>> i; // { dg-error "12: .>>. should be .> >. within a nested > template argument list" } > +/* { dg-begin-multiline-output "" } > + foo<foo<int>> i; > + ^~ > + > > > + { dg-end-multiline-output "" } */ > -- > 1.8.5.3 >