aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-05-19 16:40:24 -0400
committerJason Merrill <jason@redhat.com>2021-05-19 23:10:28 -0400
commitfe9a6614a16b5ea7f12141c50b6b7de984390ed8 (patch)
treed650424172bcd8f634842435403a8c00a3874a3a /gcc
parent65f32e5d6bbeb93a7d8d121fd56af6555e16d747 (diff)
downloadgcc-fe9a6614a16b5ea7f12141c50b6b7de984390ed8.zip
gcc-fe9a6614a16b5ea7f12141c50b6b7de984390ed8.tar.gz
gcc-fe9a6614a16b5ea7f12141c50b6b7de984390ed8.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/testsuite/g++.dg/parse/access13.C7
2 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 860ed79..aa20271 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 0000000..41463c5
--- /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" }
+};