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:
parent
75791bab05
commit
71b308914e
4 changed files with 23 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
10
gcc/testsuite/g++.dg/template/double-greater-than-fixit.C
Normal file
10
gcc/testsuite/g++.dg/template/double-greater-than-fixit.C
Normal 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 "" } */
|
Loading…
Add table
Reference in a new issue