[PR c++/84836] ICE with local scopes
authorNathan Sidwell <nathan@acm.org>
Wed, 21 Mar 2018 10:59:28 +0000 (10:59 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 21 Mar 2018 10:59:28 +0000 (10:59 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-03/msg01082.html
PR c++/84836
* name-lookup.c (update_binding): Correct logic for local binding
update.

PR c++/84836
* g++.dg/lookup/pr84836.C: New.

From-SVN: r258711

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

index f3ed02d1820f639e4da204bb98daf85e22ffb588..5a37c8235bfe24b2910bdc1b2d68bbbe8c05cb6e 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84836
+       * name-lookup.c (update_binding): Correct logic for local binding
+       update.
+
 2018-03-21  Marek Polacek  <polacek@redhat.com>
 
        PR c++/71638, ICE with NSDMI and reference.
index 411a79696a19ee8352f7d9e923c3c2679f6774a5..eda565551fb42fcaaf9025c0c017e577283e7a69 100644 (file)
@@ -2481,21 +2481,12 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot,
  done:
   if (to_val)
     {
-      if (level->kind != sk_namespace
-         && !to_type && binding->value && OVL_P (to_val))
-       update_local_overload (binding, to_val);
+      if (level->kind == sk_namespace || to_type == decl || to_val == decl)
+       add_decl_to_level (level, decl);
       else
        {
-         tree to_add = to_val;
-      
-         if (level->kind == sk_namespace)
-           to_add = decl;
-         else if (to_type == decl)
-           to_add = decl;
-         else if (TREE_CODE (to_add) == OVERLOAD)
-           to_add = build_tree_list (NULL_TREE, to_add);
-
-         add_decl_to_level (level, to_add);
+         gcc_checking_assert (binding->value && OVL_P (binding->value));
+         update_local_overload (binding, to_val);
        }
 
       if (slot)
index 3863758aeb59070d2f52c573997eedda24f5d79a..ee0a40bab3dc3a7393d98772a5d72d8f76816064 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/84836
+       * g++.dg/lookup/pr84836.C: New.
+
 2018-03-21  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/84969
diff --git a/gcc/testsuite/g++.dg/lookup/pr84836.C b/gcc/testsuite/g++.dg/lookup/pr84836.C
new file mode 100644 (file)
index 0000000..558003a
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/84836
+// ICE popping local binding
+
+void foo (void)
+{
+  struct A;
+  void A (int);
+  void A (long);
+}