-
- Downloads
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.
Loading
Please register or sign in to comment