https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104319

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:a282da2243103d79262ca04f5e3a3cc7b9b06935

commit r13-40-ga282da2243103d79262ca04f5e3a3cc7b9b06935
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Apr 29 13:50:10 2022 +0200

    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  <ja...@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.
  • [Bug c++/104319] better error m... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to