[gcc(refs/vendors/redhat/heads/gcc-10-branch)] [pr84733] Fix ICE popping local scope
Jakub Jelinek
jakub@gcc.gnu.org
Sat Mar 28 09:43:40 GMT 2020
https://gcc.gnu.org/g:c7fc15f54b321b2522ae26abebb86957de5c6fae
commit c7fc15f54b321b2522ae26abebb86957de5c6fae
Author: Nathan Sidwell <nathan@acm.org>
Date: Fri Mar 27 13:09:12 2020 -0700
[pr84733] Fix ICE popping local scope
PR c++/84733
* name-lookup.c (do_pushdecl): Look through cleanp levels.
Diff:
---
gcc/cp/ChangeLog | 5 +++++
gcc/cp/name-lookup.c | 3 ++-
gcc/testsuite/g++.dg/lookup/pr84733.C | 21 +++++++++++++++++++++
gcc/testsuite/g++.dg/lookup/pr94257.C | 16 ++++++++++++++++
4 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2a2e6eac7bf..885f29d8c86 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-27 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/84733
+ * name-lookup.c (do_pushdecl): Look through cleanp levels.
+
2020-03-27 Martin Sebor <msebor@redhat.com>
PR c++/94078
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index e6dfb9cc723..8dd0b0d723e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2998,7 +2998,8 @@ do_pushdecl (tree decl, bool is_friend)
/* The binding level we will be pushing into. During local class
pushing, we want to push to the containing scope. */
cp_binding_level *level = current_binding_level;
- while (level->kind == sk_class)
+ while (level->kind == sk_class
+ || level->kind == sk_cleanup)
level = level->level_chain;
/* An anonymous namespace has a NULL DECL_NAME, but we still want to
diff --git a/gcc/testsuite/g++.dg/lookup/pr84733.C b/gcc/testsuite/g++.dg/lookup/pr84733.C
new file mode 100644
index 00000000000..d0394eab891
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/pr84733.C
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++11 } }
+// PR c++/84733 ICE popping local binding after cleanup region
+
+struct c {
+ ~c();
+} b;
+
+void f() {
+#ifndef OK
+ try {
+ d:
+ ;
+ } catch (int) {
+ }
+#endif
+ decltype(b) a;
+ int e;
+ struct e { } f;
+ e = 5;
+ struct e j;
+}
diff --git a/gcc/testsuite/g++.dg/lookup/pr94257.C b/gcc/testsuite/g++.dg/lookup/pr94257.C
new file mode 100644
index 00000000000..d92e2920cd0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/pr94257.C
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++11 } }
+// PR94257 ICE with silly inline nest.
+
+inline namespace B { // { dg-message "namespace B { }" }
+namespace B { } // { dg-message "namespace B::B { }" }
+}
+
+namespace B { // { dg-error ".namespace B. is ambiguous" }
+}
+
+// But this is fine
+namespace D {
+inline namespace D { }
+}
+namespace D {
+}
More information about the Gcc-cvs
mailing list