public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-932] c++: ICE with using and enum [PR100659]
Date: Thu, 20 May 2021 03:11:21 +0000 (GMT)	[thread overview]
Message-ID: <20210520031121.38B5A384843E@sourceware.org> (raw)

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

commit r12-932-gfe9a6614a16b5ea7f12141c50b6b7de984390ed8
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 19 16:40:24 2021 -0400

    c++: ICE with using and enum [PR100659]
    
    Here the code for 'using enum' is confused by the combination of a
    using-decl and an enum that are not from 'using enum'; this CONST_DECL is
    from the normal unscoped enum scoping.
    
            PR c++/100659
    
    gcc/cp/ChangeLog:
    
            * cp-tree.h (CONST_DECL_USING_P): Check for null TREE_TYPE.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/parse/access13.C: New test.

Diff:
---
 gcc/cp/cp-tree.h                      | 1 +
 gcc/testsuite/g++.dg/parse/access13.C | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 860ed795299..aa202715873 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3553,6 +3553,7 @@ struct GTY(()) lang_decl {
    created by handle_using_decl.  */
 #define CONST_DECL_USING_P(NODE)			\
   (TREE_CODE (NODE) == CONST_DECL			\
+   && TREE_TYPE (NODE)					\
    && TREE_CODE (TREE_TYPE (NODE)) == ENUMERAL_TYPE	\
    && DECL_CONTEXT (NODE) != TREE_TYPE (NODE))
 
diff --git a/gcc/testsuite/g++.dg/parse/access13.C b/gcc/testsuite/g++.dg/parse/access13.C
new file mode 100644
index 00000000000..41463c5dde5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/access13.C
@@ -0,0 +1,7 @@
+// PR c++/100659
+
+template <typename> struct A
+{
+  A::E::V;		       // { dg-warning "access decl" }
+  enum { V };		       // { dg-error "conflicts with a previous decl" }
+};


                 reply	other threads:[~2021-05-20  3:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210520031121.38B5A384843E@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@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).