diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-08-27 23:33:02 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-08-27 23:33:02 +0000 |
commit | bdd039843c2df9c7ab1ebcd914a70208aaa14c23 (patch) | |
tree | 3c85ac088c15309e8f7b0a515cc378c4e9c35970 /gcc/cp/parser.c | |
parent | 6a2a69287c6cbcfa31cd9dcb13cfdf40cdd29d8e (diff) | |
download | gcc-bdd039843c2df9c7ab1ebcd914a70208aaa14c23.zip gcc-bdd039843c2df9c7ab1ebcd914a70208aaa14c23.tar.gz gcc-bdd039843c2df9c7ab1ebcd914a70208aaa14c23.tar.bz2 |
C++: fix-it hint for missing "typename" (PR c++/63392)
This patch adds a fix-it hint to missing "typename" errors in the C++
frontend, suggesting the insertion of "typename ".
This addresses part of PR c++/63392; however it does not improve the
error-recovery for such cases.
gcc/cp/ChangeLog:
PR c++/63392
* parser.c (cp_parser_diagnose_invalid_type_name): Add fix-it
hint.
gcc/testsuite/ChangeLog:
PR c++/63392
* g++.dg/diagnostic/missing-typename.C: New test.
From-SVN: r263899
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d8d4301..8291b13 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3405,8 +3405,10 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id, else if (TYPE_P (parser->scope) && dependent_scope_p (parser->scope)) { + gcc_rich_location richloc (location); + richloc.add_fixit_insert_before ("typename "); if (TREE_CODE (parser->scope) == TYPENAME_TYPE) - error_at (location, + error_at (&richloc, "need %<typename%> before %<%T::%D::%E%> because " "%<%T::%D%> is a dependent scope", TYPE_CONTEXT (parser->scope), @@ -3415,7 +3417,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id, TYPE_CONTEXT (parser->scope), TYPENAME_TYPE_FULLNAME (parser->scope)); else - error_at (location, "need %<typename%> before %<%T::%E%> because " + error_at (&richloc, "need %<typename%> before %<%T::%E%> because " "%qT is a dependent scope", parser->scope, id, parser->scope); } |