C++: add fixit for '>>' template error

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.

From-SVN: r239873
This commit is contained in:
David Malcolm 2016-08-30 21:21:42 +00:00 committed by David Malcolm
parent 75791bab05
commit 71b308914e
4 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2016-08-30 David Malcolm <dmalcolm@redhat.com>
* parser.c (cp_parser_enclosed_template_argument_list): Add fix-it
hint to ">>" within nested template argument list error.
2016-08-30 David Malcolm <dmalcolm@redhat.com>
* name-lookup.c (suggest_alternatives_for): Use add_fixit_replace

View file

@ -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;
}

View file

@ -1,3 +1,7 @@
2016-08-30 David Malcolm <dmalcolm@redhat.com>
* g++.dg/template/double-greater-than-fixit.C: New test case.
2016-08-30 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt57.ad[sb]: New test.

View file

@ -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 "" } */