re PR c++/70522 (Hidden friend functions block qualified name lookup into nested...
authorJason Merrill <jason@redhat.com>
Tue, 19 Apr 2016 13:40:03 +0000 (09:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 19 Apr 2016 13:40:03 +0000 (09:40 -0400)
PR c++/70522

* name-lookup.c (qualified_lookup_using_namespace): Look through
hidden names.

From-SVN: r235206

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

index c50c6abd6160b7e4b2dc46c0dbf2e6b122780f45..056e91740c0a5a1e4c627888f2e19663693fe0ac 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/70522
+       * name-lookup.c (qualified_lookup_using_namespace): Look through
+       hidden names.
+
 2016-04-18  Michael Matz  <matz@suse.de>
 
        * class.c (build_vtable): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
index 89d84d7b1c3982c67210c221c845c134017fb12a..b3828c0956b4bfb35c4204f334eb22e8a9c743d5 100644 (file)
@@ -4647,8 +4647,9 @@ qualified_lookup_using_namespace (tree name, tree scope,
            cp_binding_level_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
          if (binding)
            {
-             found_here = true;
              ambiguous_decl (result, binding, flags);
+             if (result->type || result->value)
+               found_here = true;
            }
 
          for (usings = DECL_NAMESPACE_USING (scope); usings;
diff --git a/gcc/testsuite/g++.dg/lookup/friend18.C b/gcc/testsuite/g++.dg/lookup/friend18.C
new file mode 100644 (file)
index 0000000..90cd2d7
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/70522
+
+namespace A {
+  struct C {
+    friend void i();
+  };
+  namespace {
+    int i;
+  }
+}
+
+int main()
+{
+  return A::i;
+}