<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58836>58836</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            friend of using declaration in non-ancestor namespace fails to compile
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          danakj
      </td>
    </tr>
</table>

<pre>
    The following code compiles on GCC and MSVC but fails on Clang. The using declaration is not able to be used as a friend, and the friend ends up trying to re-declare F in `namespace bar` as I understand it.

```
<source>:14:12: error: declaration conflicts with target of using declaration already in scope
    friend class F;
           ^
<source>:4:7: note: target of using declaration
class F {};
      ^
<source>:10:14: note: using declaration
using ::foo::F;
             ^
1 error generated.
```

https://godbolt.org/z/YerM38Ya9

```cpp
namespace foo {

template <class T>
class F {};

}  // namespace foo

namespace bar {

using ::foo::F;

class S {
    template <class T>
    friend class F;
};

}  // namespace bar
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVE1vnDAQ_TVwGQXxzXLgkOwmVQ85JaqUo8ED69RrI9s0Sn99x0C6m9VmW2QG2zOe9-bZptX8vXneI_RaSv0m1ACd5kjmMAqJFrSCb9stMMXh8enHFtrJQc-EnD1bydQQgV8_Wb-WYyeZYU6QU1hQ2gFrJYLT0PoY5MAsMOiNQMWDdEnsPP48A_RamEZw5t3no3UGb5asCA8gFARlrNgB7cg6hJYZGvuc32FSHI11PqFwURDvgvh2tWW8tmWYba2eTIdBdh9kt0nuTUoG0BhtfOe0jk6rXorOWXgTbg-OmQEd6P5CyUwaZPzd07SdHnHBA3rW8ijUWngIsruja32C4v4iPc-u8pxITPTfKwSWBCsIBNVdUO3OsL6CSeIPKf4CfZF-maYAar3WS-diSSdoyaItDKiQkiGPLm_NbPfOjdbnTR-oDZq3WrpIm4FGv-l9QfOYbV5YfXGTu3FcZo7HhGjOapyEOzyMkohQIdtFsGcvxDUBV1vtqK6ZGXxCOA36dELPof8h4CmHp-NaL-c10ldO2f8W4W_TZy1DbJKyrKo6L_M65E3G66xmoRNOYrOiXbwJdAOUVjdMdWgd7fuJUvPPgy72-osJJyObsx2neza1EQXQQMpfH5-b0ehX7BwNhbUTWuoUm01Whvum6NNuk7V1EudVm_M45XmOLK2KMq6rKsNQshalbYLiLkhThW8wp6B-UOxC0aRxmiZJXMV5UqV1VLfYF5uqouPU57xPgjzGAzGPPA9_FEPTzJTaabDklMI6e3SS_mJQiDMc5WeT22vTcKbYz9dwRm5m5n8Af42jRQ">