[Bug c++/95560] [8/9/10/11 Regression] ICE in comptypes, at cp/typeck.c:1498 since r7-4206-g84ff4775d41b716c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95560 --- Comment #7 from CVS Commits --- The releases/gcc-10 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:23dd42562369911a92d7da045ebe2c03b286a769 commit r10-8281-g23dd42562369911a92d7da045ebe2c03b286a769 Author: Marek Polacek Date: Thu Jun 11 16:35:33 2020 -0400 c++: Fix ICE in check_local_shadow with enum [PR95560] Another indication that perhaps this warning is emitted too early. We crash because same_type_p gets a null type: we have an enumerator without a fixed underlying type and finish_enum_value_list hasn't yet run. So check if the type is null before calling same_type_p. PR c++/95560 * name-lookup.c (check_local_shadow): Check if types are non-null before calling same_type_p. * g++.dg/warn/Wshadow-local-3.C: New test.
[Bug c++/95560] [8/9/10/11 Regression] ICE in comptypes, at cp/typeck.c:1498 since r7-4206-g84ff4775d41b716c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95560 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #6 from Marek Polacek --- We have a CONST_DECL with null type -- it's the case when the underlying type is not fixed, and finish_enum_value_list hasn't yet run. A stopgap fix would be --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2762,7 +2762,9 @@ check_local_shadow (tree decl) enum opt_code warning_code; if (warn_shadow) warning_code = OPT_Wshadow; - else if (same_type_p (TREE_TYPE (old), TREE_TYPE (decl)) + else if ((TREE_TYPE (old) + && TREE_TYPE (decl) + && same_type_p (TREE_TYPE (old), TREE_TYPE (decl))) || TREE_CODE (decl) == TYPE_DECL || TREE_CODE (old) == TYPE_DECL || (!dependent_type_p (TREE_TYPE (decl))