diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-03-19 14:07:07 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-03-19 14:07:07 +0000 |
commit | 8f3284a4866183caec602737f35c088d982e18bb (patch) | |
tree | cf5836b4dd649317ac52ccb8af41202f384510b2 | |
parent | 25f91fda52f88f4a639a30ec33d821f1acb9c058 (diff) | |
download | gcc-8f3284a4866183caec602737f35c088d982e18bb.zip gcc-8f3284a4866183caec602737f35c088d982e18bb.tar.gz gcc-8f3284a4866183caec602737f35c088d982e18bb.tar.bz2 |
[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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/pr84812.C | 18 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a8da08..6622603 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-19 Nathan Sidwell <nathan@acm.org> + + PR c++/84812 + * name-lookup.c (set_local_extern_decl_linkage): Defend against + ambiguous lookups. + 2018-03-16 Jakub Jelinek <jakub@redhat.com> PR c/84910 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 80a92ab..cc8bb2f 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 868d8e8..337b4bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-19 Nathan Sidwell <nathan@acm.org> + + PR c++/84812 + * g++.dg/lookup/pr84812.C: New. + 2018-03-19 Richard Biener <rguenther@suse.de> 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 0000000..9cff222 --- /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" } } |