]> gcc.gnu.org Git - gcc.git/commitdiff
c++: ICE with using and enum [PR100659]
authorJason Merrill <jason@redhat.com>
Wed, 19 May 2021 20:40:24 +0000 (16:40 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 20 May 2021 03:10:28 +0000 (23:10 -0400)
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.

gcc/cp/cp-tree.h
gcc/testsuite/g++.dg/parse/access13.C [new file with mode: 0644]

index 860ed795299345a066c5a47d238dce2c5f3d2c23..aa202715873b28ddbcb3f993574ac0ad411609f8 100644 (file)
@@ -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 (file)
index 0000000..41463c5
--- /dev/null
@@ -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" }
+};
This page took 0.081989 seconds and 5 git commands to generate.