cp_binding_level_find_binding_for_name can find a binding for a hidden
friend declaration, in which case we shouldn't stop looking into
anonymous namespaces. This bug blocked the use of N4381 customization
points.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 995a41f6f9153cbc4ec713ec645a3edebc408ec2
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Apr 19 09:11:38 2016 -0400
PR c++/70522
* name-lookup.c (qualified_lookup_using_namespace): Look through
hidden names.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 89d84d7..b3828c0 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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
index 0000000..90cd2d7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/friend18.C
@@ -0,0 +1,15 @@
+// PR c++/70522
+
+namespace A {
+ struct C {
+ friend void i();
+ };
+ namespace {
+ int i;
+ }
+}
+
+int main()
+{
+ return A::i;
+}