diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-08-30 21:21:42 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2016-08-30 21:21:42 +0000 |
commit | b7ceaf9aa03b700f8e792216e8e37a8ecc57f0cf (patch) | |
tree | 8c4de93c8c6aaf35474d2b10310efa9ce40c1421 | |
parent | edde4d27c09fc8065f6ab2870f2b960ad5c5a067 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@239873 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/double-greater-than-fixit.C | 10 |
4 files changed, 23 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7ae6f53f7e4..c553796d7bf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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 rather than add_fixit_misspelled_id. * parser.c (cp_parser_diagnose_invalid_type_name): Likewise. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 48dbca17bc4..ca9f8b9761a 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/ChangeLog b/gcc/testsuite/ChangeLog index ffd44916917..6e3b70662d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. 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 00000000000..f0de4ec35b5 --- /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 "" } */ |