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

    <tr>
        <th>Summary</th>
        <td>
            "1st argument ('__restrict int') would lose restrict qualifier" when passing (this restrict *)->int to int& argument
        </td>
    </tr>

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

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

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

<pre>
    ```cpp
void f(int& x) {
    (void)x;
}

class C {
    int x;
    void g() __restrict;
};

void C::g() __restrict {
    f(this->x);
}
```
(same for `void f(int const& x)`) compiles fine on GCC, but Clang 17 and 19.0.0 (++20240212105217+93cdd1b5cfa3-1\~exp1\~20240212225341.524) rejects it with
```
a.cpp:11:5: error: no matching function for call to 'f'
   11 |     f(this->x);
      |     ^
a.cpp:1:6: note: candidate function not viable: 1st argument ('__restrict int') would lose restrict qualifier
    1 | void f(int& x) {
      |      ^ ~~~~~~
1 error generated.
```

I don't think this is valid – this looks like `this` is of type `C restrict *`, and thus `x` is compatible with `int restrict &`, and it's treating restrict like a cv-qualifier, which I don't think it is, and even if it were I haven't found a position where you *could* make f take an `int restrict &` (which I don't think makes much sense given reference validity semantics and the C++ object model).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1y4zgPPQ28QcUlQdbfQgtHnXzVp-iiKEhihyL9iZSdzKLPPkXKsZOezMxmXC6SJgAC7-GRFs6p0TA3kD9C_m0nVj_ZpTGiUz-F_EPzhbXadbZ_a6BItq88nSD5BsnxbFWPA1CljAcq8BWoRigfNysiIlAVnIDqV8iu-1B-uy7iKLVwDtvPccp4vEeEnZhrBKpCjh8_FnZ-UdJ_OvW2vlfXQnaE7PjXwM_5Agg_KfcA2VNA8UWx7-ivP6lyYmYc7IJQJB-ZQGmNu_ERIqhGaeeT0uxwUIbRGvxf2wK12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