From: Nathan Sidwell Date: Tue, 5 Dec 2017 17:29:58 +0000 (+0000) Subject: [PR C++/83287] Mark lookup for keeping X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea9e71de65fd640620938a463d30408f92fea8d1;p=gcc.git [PR C++/83287] Mark lookup for keeping https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00242.html PR c++/83287 * tree.c (build_min): Check CAST_EXPR arg for OVERLOADs. * g++.dg/lookup/pr83287.C: New. From-SVN: r255429 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5ab703d1d3..d5141f03847 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-12-05 Nathan Sidwell + + PR c++/83287 + * tree.c (build_min): Check CAST_EXPR arg for OVERLOADs. + 2017-12-05 Martin Liska Jakub Jelinek diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c76dea46479..43bbf438eae 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3230,6 +3230,13 @@ build_min (enum tree_code code, tree tt, ...) } va_end (p); + + if (code == CAST_EXPR) + /* The single operand is a TREE_LIST, which we have to check. */ + for (tree v = TREE_OPERAND (t, 0); v; v = TREE_CHAIN (v)) + if (TREE_CODE (TREE_VALUE (v)) == OVERLOAD) + lookup_keep (TREE_VALUE (v), true); + return t; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41099b47ae8..58a4c002dc3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-05 Nathan Sidwell + + PR c++/83287 + * g++.dg/lookup/pr83287.C: New. + 2017-12-05 Jakub Jelinek PR testsuite/83289 diff --git a/gcc/testsuite/g++.dg/lookup/pr83287.C b/gcc/testsuite/g++.dg/lookup/pr83287.C new file mode 100644 index 00000000000..305407bf5e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr83287.C @@ -0,0 +1,19 @@ +// PR c++/83287 failed to keep lookup until instantiation time + +void foo (); + +namespace { + void foo (int); +} + +template +void bar () +{ + T (*p)() = (T (*)(void)) foo; +} + +void +baz () +{ + bar (); +}