]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix ICE popping local scope [pr84733]
authorNathan Sidwell <nathan@acm.org>
Fri, 27 Mar 2020 20:13:39 +0000 (13:13 -0700)
committerNathan Sidwell <nathan@acm.org>
Fri, 27 Mar 2020 20:13:39 +0000 (13:13 -0700)
PR c++/84733
* name-lookup.c (do_pushdecl): Look through cleanp levels.

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/lookup/pr84733.C [new file with mode: 0644]

index 8edc445e70e98e7e17b5aeb9a15accb87a8d3832..91c01f543a554ab347cc79b11b864b3b306d2cdc 100644 (file)
@@ -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-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/92909
index 8999c5ad4a74d0253d1ac544f5df0e9c6a91703a..8298ee171e0aa344151fad9a9ab88af09a45c82c 100644 (file)
@@ -2988,7 +2988,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 (file)
index 0000000..d0394ea
--- /dev/null
@@ -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;
+}