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

    <tr>
        <th>Summary</th>
        <td>
            [clang-16 regression] Nested template friend function declaration inside template class clashes with different symbol in inline namespace
        </td>
    </tr>

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

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

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

<pre>
    Reproducible on clang 16/trunk (and 10), but not 11-15 or gcc:

```cpp
namespace A {
    inline namespace B {
        inline constexpr struct {} foo;
    }

    template <typename T>
    class Bar {
        template <typename U>
 friend void foo(U &&arg) {}
    };
}

void foobar() {
 A::Bar<int> b;
}
```

clang-16 and trunk reject this with:
```
<source>:9:21: error: redefinition of 'foo' as different kind of symbol
        friend void foo(U &&arg) {}
 ^
<source>:14:17: note: in instantiation of template class 'A::Bar<int>' requested here
    A::Bar<int> b;
                ^
<source>:3:36: note: previous definition is here
        inline constexpr struct {} foo;
                                   ^
1 error generated.
Compiler returned: 1
```

Changing either `Bar` to be a non-template, or the `friend foo()` declaration to be a non-template allows it to compile without issue.

godbolt link: https://godbolt.org/z/q38sanqMY
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1z4zYM_TX0BWOPRNr6OOjgj_jWHjrdQ48UCUvc0KQCUknTX9-hFMeO626nq7EpD0GAD-8BsAzBdA6xYZsd2xwWcoy9p-a7Jj_2kvSi9fq9-Q0H8npUprUI3oGy0nWQF4wfI43uGRivpNOQZ4zXjO-hHSM4HyHPl_kGPEGnFBNblh1YdlmLbP6oYZh3nDxjGKRC2AIrd_MmAIBx1jiEq3331X5zRnkXIv45EIRIo4rTwfIAJ--ZuHFh5eEWTNqKeB6sjAhM7OP7gOk6-J2Jp-sRZWUIsJP0z_sfen-7ep_IoNPw6o2ewPDqGzBeMF5I6hivP4B-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