c++: Fix ICE in check_local_shadow with enum [PR95560]
authorMarek Polacek <polacek@redhat.com>
Tue, 16 Jun 2020 17:02:23 +0000 (13:02 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 16 Jun 2020 17:08:57 +0000 (13:08 -0400)
commit2661635323bd44410f1a154683eccecd2c163b46
tree615689aa0a6b034cbb0fbfc0cd3973d2e3961ff6
parent43a9b25c17d264b81832e3bc09135f736c9e42ec
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.
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/warn/Wshadow-local-3.C [new file with mode: 0644]