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

    <tr>
        <th>Summary</th>
        <td>
            clang rejects valid friend template function declaration with noexcept specifier in template class
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    The following code is rejected by clang for the mismatch of the `noexcept` specifier between the friend declaration and definition of `func`:

```c++
template <typename T>
struct C {
    template <int N>
    friend void func() noexcept(N == 0);
};

template <int N>
void func() noexcept(N == 0) {}

int main() {
    C<int> t;
    return 0;
}
```
The diagnostic says that:

```c++
<source>:4:17: error: exception specification in declaration does not match the previous declaration
    4 |     friend void func() noexcept(N == 0);
      |                 ^
<source>:11:12: note: in instantiation of template class 'C<int>' requested here
   11 | C<int> t;
      |            ^
<source>:8:6: note: previous declaration is here
    8 | void func() noexcept(N == 0) {}
```

That is quite unreasonable. It should be clear that the `noexcept` expression of `func` keeps identical between the friend declaration and definition statement. Removing the dependent name `N` in the `noexcept` expression or replacing template class `C` with a non-template one can eliminate the diagnostic. 

[https://godbolt.org/z/rPh84Phzn](https://godbolt.org/z/rPh84Phzn)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV9vozgQ_zSTl1EjsCGEBx7apJHupVqt9gsYMwTfGZu1TbrdT3-yk6Zh29X17qIIMMyf38_z84zwXh0NUQPlA5T7lZjDYF3zdfZDnjHOV63tXppvA2FvtbbPyhxR2o5QeXT0J8lAHbYvKLUwR-ytwzAQjsqPIsgBbZ_WsMmMpR-SpgCbDP1EUvWKHLYUnolMMuqdItNhR1ILJ4KyBkVa98qotLR9jNTPRsImA34P2R6y1-smO_8lsIf4T28DjZMWgRD4LrxMZMRI-A344_mzD26WAXcI1cUBEfHWSZmAT1f7-PUC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