On 02/09/2016 03:29 PM, Rainer Orth wrote:
This patch broke Solaris bootstrap (seen on i386-pc-solaris2.12):
Fixed by pruning hidden names from the lookup result in more places. Jason
commit 09bb9e19d3f284c2f9d8bf57959c99334363c3c9 Author: Jason Merrill <ja...@redhat.com> Date: Tue Feb 9 16:20:46 2016 -0500 PR c++/69657 * name-lookup.c (ambiguous_decl): Call remove_hidden_names. (lookup_name_real_1): Likewise. (remove_hidden_names): Handle non-functions too. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 227d6f2..8d6e75a 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4221,9 +4221,9 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags) val = new_binding->value; if (val) { - if (hidden_name_p (val) && !(flags & LOOKUP_HIDDEN)) - val = NULL_TREE; - else + if (!(flags & LOOKUP_HIDDEN)) + val = remove_hidden_names (val); + if (val) switch (TREE_CODE (val)) { case TEMPLATE_DECL: @@ -4353,7 +4353,7 @@ hidden_name_p (tree val) return false; } -/* Remove any hidden friend functions from a possibly overloaded set +/* Remove any hidden declarations from a possibly overloaded set of functions. */ tree @@ -4362,7 +4362,7 @@ remove_hidden_names (tree fns) if (!fns) return fns; - if (TREE_CODE (fns) == FUNCTION_DECL && hidden_name_p (fns)) + if (DECL_P (fns) && hidden_name_p (fns)) fns = NULL_TREE; else if (TREE_CODE (fns) == OVERLOAD) { @@ -4931,6 +4931,10 @@ lookup_name_real_1 (tree name, int prefer_type, int nonclass, bool block_p, if (!val) val = unqualified_namespace_lookup (name, flags); + /* Anticipated built-ins and friends aren't found by normal lookup. */ + if (val && !(flags & LOOKUP_HIDDEN)) + val = remove_hidden_names (val); + /* If we have a single function from a using decl, pull it out. */ if (val && TREE_CODE (val) == OVERLOAD && !really_overloaded_fn (val)) val = OVL_FUNCTION (val); diff --git a/gcc/testsuite/g++.dg/lookup/builtin7.C b/gcc/testsuite/g++.dg/lookup/builtin7.C new file mode 100644 index 0000000..c612d8c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/builtin7.C @@ -0,0 +1,14 @@ +// PR c++/69657 + +typedef unsigned int size_t; +namespace std { +extern void *calloc(size_t, size_t); +} +using std::calloc; +int +main () +{ + char *(*pfn) = (char *(*)) calloc ; + (bool)&calloc; + (bool)&::calloc; +}