From: Jason Merrill Date: Wed, 19 May 2021 20:40:24 +0000 (-0400) Subject: c++: ICE with using and enum [PR100659] X-Git-Tag: releases/gcc-11.2.0~359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b7212ebb80e854c08274228627ce0a3061db6b0;p=thirdparty%2Fgcc.git 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 --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index fbf33b9150ee..17ba7cbd2229 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3529,6 +3529,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 000000000000..41463c5dde5e --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/access13.C @@ -0,0 +1,7 @@ +// PR c++/100659 + +template struct A +{ + A::E::V; // { dg-warning "access decl" } + enum { V }; // { dg-error "conflicts with a previous decl" } +};