public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/90995] [8/9 Regression] ICE in grokdeclarator, at cp/decl.c:12024
Date: Tue, 07 Apr 2020 19:03:25 +0000	[thread overview]
Message-ID: <bug-90995-4-5H9tdOfbyY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-90995-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:980a7a0be5a114e285c49ab05ac70881e4f27fc3

commit r9-8462-g980a7a0be5a114e285c49ab05ac70881e4f27fc3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 17 21:21:16 2020 +0100

    c++: Fix parsing of invalid enum specifiers [PR90995]

    The testcase shows some accepts-invalid (the ones without alignas) and
    ice-on-invalid-code (the ones with alignas) cases.
    If the enum doesn't have an underlying type and is not a definition,
    the caller retries to parse it as elaborated type specifier.
    E.g. for enum struct S s it will then pedwarn that elaborated type
specifier
    shouldn't have the struct/class keywords.
    The problem is if the enum specifier is not followed by { when it has
    underlying type.  In that case we have already called
    cp_parser_parse_definitely to end the tentative parsing started at the
    beginning of cp_parser_enum_specifier.  But the
    cp_parser_error (parser, "expected %<;%> or %<{%>");
    doesn't emit any error because the whole function is called from yet
another
    tentative parse and the caller starts parsing the elaborated type
    specifier where the cp_parser_enum_specifier stopped (i.e. after the
    underlying type token(s)).  The ultimate caller than commits the tentative
    parsing (and even if it wouldn't, it wouldn't know what kind of error
    to report).  I think after seeing enum {,struct,class} : type not being
    followed by { or ;, there is no reason not to report it right away, as it
    can't be valid C++, which is what the patch does.  Not sure if we shouldn't
    also return error_mark_node instead of NULL_TREE, so that the caller
doesn't
    try to parse it as elaborated type specifier (the patch doesn't do that
    right now).

    Furthermore, while reading the code, I've noticed that
    parser->colon_corrects_to_scope_p is saved and set to false at the start
    of the function, but not restored back in some cases.  Don't have a
testcase
    where this would be a problem, but it just seems wrong.  Either we can in
    the two spots replace return NULL_TREE; with { type = NULL_TREE; goto out;
}
    or we could perhaps abuse warning_sentinel or create a special class with
    dtor to clean the flag up.

    And lastly, I've fixed some formatting issues in the function while reading
    it.

    2020-03-17  Jakub Jelinek  <jakub@redhat.com>

            PR c++/90995
            * parser.c (cp_parser_enum_specifier): Use temp_override for
            parser->colon_corrects_to_scope_p, replace goto out with return.
            If scoped enum or enum with underlying type is not followed by
            { or ;, call cp_parser_commit_to_tentative_parse before calling
            cp_parser_error and make sure to return error_mark_node instead of
            NULL_TREE.  Formatting fixes.

            * g++.dg/cpp0x/enum40.C: New test.

  parent reply	other threads:[~2020-04-07 19:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-90995-4@http.gcc.gnu.org/bugzilla/>
2020-03-13 20:51 ` [Bug c++/90995] [8/9/10 " jakub at gcc dot gnu.org
2020-03-17 20:22 ` cvs-commit at gcc dot gnu.org
2020-03-17 20:22 ` [Bug c++/90995] [8/9 " jakub at gcc dot gnu.org
2020-04-07 19:03 ` cvs-commit at gcc dot gnu.org [this message]
2020-04-07 20:00 ` [Bug c++/90995] [8 " jakub at gcc dot gnu.org
2020-09-17 14:25 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:12 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-90995-4-5H9tdOfbyY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).