PR c++/69657
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Feb 2016 15:34:59 +0000 (15:34 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Feb 2016 15:34:59 +0000 (15:34 +0000)
* name-lookup.c (ambiguous_decl): Call remove_hidden_names.
(lookup_name_real_1): Likewise.
(remove_hidden_names): Handle non-functions too.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233278 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/lookup/builtin7.C [new file with mode: 0644]

index 92e65fc..628f4d1 100644 (file)
@@ -1,5 +1,10 @@
 2016-02-10  Jason Merrill  <jason@redhat.com>
 
+       PR c++/69657
+       * name-lookup.c (ambiguous_decl): Call remove_hidden_names.
+       (lookup_name_real_1): Likewise.
+       (remove_hidden_names): Handle non-functions too.
+
        PR c++/10200
        * parser.c (cp_parser_lookup_name): When looking for a template
        after . or ->, only consider class templates.
index 227d6f2..8d6e75a 100644 (file)
@@ -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 (file)
index 0000000..c612d8c
--- /dev/null
@@ -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;
+}