Commit 71b30891 by David Malcolm Committed by David Malcolm

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
parent 75791bab
2016-08-30 David Malcolm <dmalcolm@redhat.com> 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 * name-lookup.c (suggest_alternatives_for): Use add_fixit_replace
rather than add_fixit_misspelled_id. rather than add_fixit_misspelled_id.
* parser.c (cp_parser_diagnose_invalid_type_name): Likewise. * parser.c (cp_parser_diagnose_invalid_type_name): Likewise.
......
...@@ -26342,8 +26342,10 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser) ...@@ -26342,8 +26342,10 @@ cp_parser_enclosed_template_argument_list (cp_parser* parser)
global source location is still on the token before the global source location is still on the token before the
'>>', so we need to say explicitly where we want it. */ '>>', so we need to say explicitly where we want it. */
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
error_at (token->location, "%<>>%> should be %<> >%> " gcc_rich_location richloc (token->location);
"within a nested template argument list"); richloc.add_fixit_replace ("> >");
error_at_rich_loc (&richloc, "%<>>%> should be %<> >%> "
"within a nested template argument list");
token->type = CPP_GREATER; token->type = CPP_GREATER;
} }
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> 2016-08-30 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt57.ad[sb]: New test. * gnat.dg/opt57.ad[sb]: New test.
......
/* { 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 "" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment