diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-04-29 13:50:10 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-04-29 13:51:36 +0200 |
commit | a282da2243103d79262ca04f5e3a3cc7b9b06935 (patch) | |
tree | cfe1e5dde10785f65afd31b6f59d8c1894a5dedf /gcc/gcov-io.cc | |
parent | 8c465ddd619bbb2949bc2bc31629c2a826a7c437 (diff) | |
download | gcc-a282da2243103d79262ca04f5e3a3cc7b9b06935.zip gcc-a282da2243103d79262ca04f5e3a3cc7b9b06935.tar.gz gcc-a282da2243103d79262ca04f5e3a3cc7b9b06935.tar.bz2 |
c++: Improve diagnostics for template args terminated with >= or >>= [PR104319]
As mentioned in the PR, for C++98 we have diagnostics that expect
>> terminating template arguments to be a mistake for > > (C++11
said it has to be treated that way), while if user trying to spare the
spacebar doesn't separate > from following = or >> from following =,
the diagnostics is confusing, while clang suggests adding space in between.
The following patch does that for >= and >>= too.
For some strange reason the error recovery emits further errors,
not really sure what's going on because I overwrite the token->type
like the code does for the C++11 >> case or for the C++98 >> cases,
but at least the first error is nicer (well, for the C++98 nested
template case and >>= I need to overwrite it to > and so the = is lost,
so perhaps some follow-up errors are needed for that case).
2022-04-29 Jakub Jelinek <jakub@redhat.com>
PR c++/104319
* parser.cc (cp_parser_template_argument): Treat >= like C++98 >>
after a type id by setting maybe_type_id and aborting tentative
parse.
(cp_parser_enclosed_template_argument_list): Handle
CPP_GREATER_EQ like misspelled CPP_GREATER CPP_RQ and
CPP_RSHIFT_EQ like misspelled CPP_GREATER CPP_GREATER_EQ
or CPP_RSHIFT CPP_EQ or CPP_GREATER CPP_GREATER CPP_EQ.
(cp_parser_next_token_ends_template_argument_p): Return true
also for CPP_GREATER_EQ and CPP_RSHIFT_EQ.
* g++.dg/parse/template28.C: Adjust expected diagnostics.
* g++.dg/parse/template30.C: New test.
Diffstat (limited to 'gcc/gcov-io.cc')
0 files changed, 0 insertions, 0 deletions