From: Nathan Sidwell Date: Mon, 19 Mar 2018 14:07:07 +0000 (+0000) Subject: [C++/84812] ICE with local fn decl X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f3284a4866183caec602737f35c088d982e18bb;p=gcc.git [C++/84812] ICE with local fn decl https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00872.html PR c++/84812 * name-lookup.c (set_local_extern_decl_linkage): Defend against ambiguous lookups. PR c++/84812 * g++.dg/lookup/pr84812.C: New. From-SVN: r258644 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a8da084445..66226033e41 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-19 Nathan Sidwell + + PR c++/84812 + * name-lookup.c (set_local_extern_decl_linkage): Defend against + ambiguous lookups. + 2018-03-16 Jakub Jelinek PR c/84910 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 80a92ab0ac4..cc8bb2f81c6 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2878,7 +2878,9 @@ set_local_extern_decl_linkage (tree decl, bool shadowed) = find_namespace_value (current_namespace, DECL_NAME (decl)); loc_value = ns_value; } - if (loc_value == error_mark_node) + if (loc_value == error_mark_node + /* An ambiguous lookup. */ + || (loc_value && TREE_CODE (loc_value) == TREE_LIST)) loc_value = NULL_TREE; for (ovl_iterator iter (loc_value); iter; ++iter) @@ -2926,7 +2928,8 @@ set_local_extern_decl_linkage (tree decl, bool shadowed) if (ns_value == decl) ns_value = find_namespace_value (current_namespace, DECL_NAME (decl)); - if (ns_value == error_mark_node) + if (ns_value == error_mark_node + || (ns_value && TREE_CODE (ns_value) == TREE_LIST)) ns_value = NULL_TREE; for (ovl_iterator iter (ns_value); iter; ++iter) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 868d8e8f7a6..337b4bd1f25 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-19 Nathan Sidwell + + PR c++/84812 + * g++.dg/lookup/pr84812.C: New. + 2018-03-19 Richard Biener PR tree-optimization/84929 diff --git a/gcc/testsuite/g++.dg/lookup/pr84812.C b/gcc/testsuite/g++.dg/lookup/pr84812.C new file mode 100644 index 00000000000..9cff2223ae8 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr84812.C @@ -0,0 +1,18 @@ +// PR 84812. ICE determining implicit "C" linkage + +struct A { void foo(); }; +struct B { void foo(); }; + +struct C : A, B +{ + void X (); +}; + +void C::X () +{ + void foo (); // local decl of ::foo + + foo (); +} + +// { dg-final { scan-assembler "_Z3foov" } }