public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "haoxintu at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95927] ICE in cp_lexer_new_from_tokens, at cp/parser.c:701
Date: Fri, 03 Jul 2020 04:17:37 +0000	[thread overview]
Message-ID: <bug-95927-4-uvgvKd35y7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95927-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Haoxin Tu <haoxintu at gmail dot com> ---
Add a more meaningful case.


$cat p.cc
template <class> struct a {};
class A {
    struct a < struct x { void b ( ){}} >;
};

$g++ p.cc
p.cc:3:25: error: types may not be defined in template arguments
    3 |     struct a < struct x { void b ( ){}} >;
      |                         ^
p.cc:3:40: error: expected ‘;’ after struct definition
    3 |     struct a < struct x { void b ( ){}} >;
      |                                        ^
      |                                        ;
p.cc:3:39: error: expected template-argument before ‘;’ token
    3 |     struct a < struct x { void b ( ){}} >;
      |                                       ^
p.cc:3:39: error: expected ‘>’ before ‘;’ token
p.cc:3:5: error: ‘struct a<A::x>’ redeclared with different access
    3 |     struct a < struct x { void b ( ){}} >;
      |     ^~~~~~
p.cc:3:41: error: expected unqualified-id before ‘>’ token
    3 |     struct a < struct x { void b ( ){}} >;
      |                                         ^
p.cc:4:1: internal compiler error: in cp_lexer_new_from_tokens, at
cp/parser.c:701
    4 | };
      | ^
0x6adadc cp_parser_push_lexer_for_tokens
        ../../gcc/cp/parser.c:701
...


While in Clang
$clang++ p.cc
p.cc:3:23: error: 'x' cannot be defined in a type specifier
    struct a < struct x { void b ( ){}} >;
                      ^
1 error generated.

I guess Clang is performed better when parsing this case. GCC emits a lot of
error messages even throw an ICE, while Clang just emits one.

  reply	other threads:[~2020-07-03  4:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-27  2:21 [Bug c++/95927] New: " haoxintu at gmail dot com
2020-07-03  4:17 ` haoxintu at gmail dot com [this message]
2020-07-08 21:50 ` [Bug c++/95927] " mpolacek at gcc dot gnu.org
2021-12-29  0:24 ` pinskia 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-95927-4-uvgvKd35y7@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).