From 4436a3ce496abccfc405ade7fb8b575ea55a64ee Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 17 Jan 2018 18:11:49 +0000 Subject: [PATCH] [C++/83287] Another overload lookup ice https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01580.html PR c++/83287 * init.c (build_raw_new_expr): Scan list for lookups to keep. PR c++/83287 * g++.dg/lookup/pr83287-2.C: New. From-SVN: r256809 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/init.c | 7 ++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/pr83287-2.C | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/lookup/pr83287-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49cf0c05a5c..71fa358f5f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-01-17 Nathan Sidwell + + PR c++/83287 + * init.c (build_raw_new_expr): Scan list for lookups to keep. + 2018-01-17 David Malcolm PR c++/83814 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1be7c67d867..233f41c2592 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2325,7 +2325,12 @@ build_raw_new_expr (vec *placement, tree type, tree nelts, else if (init->is_empty ()) init_list = void_node; else - init_list = build_tree_list_vec (init); + { + init_list = build_tree_list_vec (init); + for (tree v = init_list; v; v = TREE_CHAIN (v)) + if (TREE_CODE (TREE_VALUE (v)) == OVERLOAD) + lookup_keep (TREE_VALUE (v), true); + } new_expr = build4 (NEW_EXPR, build_pointer_type (type), build_tree_list_vec (placement), type, nelts, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6c744e60de..da2cc0b1cfe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-17 Nathan Sidwell + + PR c++/83287 + * g++.dg/lookup/pr83287-2.C: New. + 2018-01-17 David Malcolm PR c++/83814 diff --git a/gcc/testsuite/g++.dg/lookup/pr83287-2.C b/gcc/testsuite/g++.dg/lookup/pr83287-2.C new file mode 100644 index 00000000000..6ea65400a42 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr83287-2.C @@ -0,0 +1,20 @@ +// PR c++/83287 failed to keep lookup until instantiation time + +void foo (); + +namespace { + void foo (); +} + +template +void +bar () +{ + new T (foo); // { dg-error "cannot resolve" } +} + +void +baz () +{ + bar (); +} -- 2.30.2