title: Is it legal to friend a function via a using declaration?
body: <p>The following <a href="http://liveworkspace.org/code/2NVszT" rel="nofollow">(LiveWorkspace here)</a> is rejected by GCC 4.7.2, GCC 4.8.0, and ICC 13.0.1.</p>
  
  <pre><code>namespace A {
      namespace B {
          void C();
      }
      using B::C;
  }
  
  class D {
      friend void A::C();
  };
  </code></pre>
  
  <p>Additionally, it crashes Clang 3.2 (!). I've submitted a bug report and <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130318/076411.html" rel="nofollow">patch</a> already, for the crash bug, but I'm not 100% sure if this code is really in error, because I can't find anything in <strong>§7.3.3 [namespace.udecl]</strong> or <strong>§11.3 [class.friend]</strong> that explicitly addresses this case, but maybe there's something in the definition of one of the various name specifier terms that I've missed.</p>
  
  <p>Furthermore, it seems like all four compilers accept the following <a href="http://liveworkspace.org/code/2rWG6L" rel="nofollow">(LiveWorkspace here)</a>:</p>
  
  <pre><code>namespace A {
      namespace B {
          class C;
      }
      using B::C;
  }
  
  class D {
      friend class A::C;
  };
  </code></pre>
  
  <p>There doesn't seem to be anything fundamentally different about these two cases, so I'm curious what GCC and ICC's grounds to reject the first example but not this one are, if any. Can anyone more familiar with the standard find anything that addresses this?</p>
  
  <p>It's definitely a minor issue at best, but since I'm patching it, I'd like to be sure I'm doing the right thing...</p>
  
  <p><strong>EDIT</strong>: <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130401/077351.html" rel="nofollow">This is patched now in clang/trunk!</a></p>
  
  <p><strong>NEW EDIT</strong>: Johannes's answer below explains why my original example is rejected, but it doesn't seem to explain why GCC and ICC also reject the following <a href="http://liveworkspace.org/code/OZOR5" rel="nofollow">(LiveWorkspace here)</a>:</p>
  
  <pre><code>namespace A {
      namespace B {
          void C();
      }
      using B::C;
  
      class D {
          friend void C();
      };
  }
  </code></pre>