From: Nathan Sidwell Date: Wed, 21 Mar 2018 10:59:28 +0000 (+0000) Subject: [PR c++/84836] ICE with local scopes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7cd9cf2f0bc24499c292896f951c2a34875637f0;p=gcc.git [PR c++/84836] ICE with local scopes 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f3ed02d1820..5a37c8235bf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-21 Nathan Sidwell + + PR c++/84836 + * name-lookup.c (update_binding): Correct logic for local binding + update. + 2018-03-21 Marek Polacek PR c++/71638, ICE with NSDMI and reference. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 411a79696a1..eda565551fb 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3863758aeb5..ee0a40bab3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-21 Nathan Sidwell + + PR c++/84836 + * g++.dg/lookup/pr84836.C: New. + 2018-03-21 Bin Cheng 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 index 00000000000..558003ad24e --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr84836.C @@ -0,0 +1,9 @@ +// PR c++/84836 +// ICE popping local binding + +void foo (void) +{ + struct A; + void A (int); + void A (long); +}