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

    <tr>
        <th>Summary</th>
        <td>
            [Modules] "Cannot befriend target of using declaration"
        </td>
    </tr>

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

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

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

<pre>
    Given the following two translation units

```cpp
module;

namespace n
{

template<typename>
struct a {
        template<typename T>
        friend void aa(a<T>);
};

template<typename T>
inline void aa(a<T>) {
}


} //namespace n

export module a;

namespace n {

export using n::a;
export using n::aa;

}
```

```cpp
import a;

void b() {
        aa(n::a<int>());
}
```

And compiling with

```shell
clang++ -std=c++20 -x c++-module --precompile -c a.cpp -o a.pcm
clang++ -w -std=c++20 -fmodule-file=a=a.pcm -c b.cpp -o /dev/null
```

Causes clang to error with

```console
In file included from b.cpp:1:
a.cpp:9:14: error: cannot befriend target of using declaration
        friend void aa(a<T>);
 ^
b.cpp:4:5: note: in instantiation of template class 'n::a<int>' requested here
        aa(n::a<int>());
           ^
a.cpp:13:13: note: target of using declaration
inline void aa(a<T>) {
 ^
a.cpp:24:17: note: using declaration
export using n::aa;
 ^
1 error generated.
```

I believe this code should be accepted, but I'm not 100% sure.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVdGS6igQ_Rry0hUrASP6kAdH16152Lf9AQKtYYtAFoje-_dbJHGc8WbmzqYUTUOfPpzuBhGCvljEmlQvpDpmYoit87USV61CdBazxqmf9Z_6ihZii3B2xribtheINwfRCxuMiNpZGKyOgRRHUuzncVNMH9n3k6VzajBI2Mv7ZVZ0GHohEexs5h_mI3a9EREJO8SfPablhP0xzYXoBxlBwDuf3YID_P3mQord2Wu0Cq5OKxCC0K0g7DCuoLsHOX58Ivo1rrZGW1wGfUePHz9IdDcCoSdCT79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