public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-10] c++: Fix ICE in check_local_shadow with enum [PR95560]
@ 2020-06-15 15:52 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2020-06-15 15:52 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:23dd42562369911a92d7da045ebe2c03b286a769
commit 23dd42562369911a92d7da045ebe2c03b286a769
Author: Marek Polacek <polacek@redhat.com>
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.
Diff:
---
gcc/cp/name-lookup.c | 4 +++-
gcc/testsuite/g++.dg/warn/Wshadow-local-3.C | 7 +++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 9b68b15be60..76f3edb04c8 100644
--- 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))
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-local-3.C b/gcc/testsuite/g++.dg/warn/Wshadow-local-3.C
new file mode 100644
index 00000000000..fd743eca347
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-local-3.C
@@ -0,0 +1,7 @@
+// PR c++/95560
+// { dg-do compile { target c++11 } }
+
+template <typename> void fn1() {
+ bool ready;
+ enum class State { ready };
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-15 15:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 15:52 [gcc/devel/omp/gcc-10] c++: Fix ICE in check_local_shadow with enum [PR95560] Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).