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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] [Sema] `friend` functions that are incorrectly redefined as deleted are not diagnosed
        </td>
    </tr>

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

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

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

<pre>
    We currently accept this code (https://godbolt.org/z/e9vzx5M6x) even though we shouldn’t (GCC, MSVC, and EDG all reject this):
```c++
struct S {
    friend int f() { return 3; }
    friend int f() = delete;
};
```

(We also crash on this at the moment, but #135679 fixes the crash, though it still accepts this unfortunately.)


Interestingly, we *do* diagnose this (https://godbolt.org/z/3b5qG979r):
```c++
struct S {
    friend int f() = delete;
    friend int f() { return 3; }
};
```

I think we have to do *something* to diagnose the above in `ParseCXXInlineMethodDef()` after we parse the `= default`/`= delete` because we currently just return. It doesn’t seem to be as simple as just calling `CheckForFunctionRedefinition()` as that breaks a bunch of tests (mostly around defaulted `operator==` from what I could tell).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVEuL5DYQ_jXqS7GNW26_Dj70Yz30YSBkILtX2Srb2pGljlTumdlfH8ru3VkGEhIICFy26_V9-qpUjGZwiLXIjiI7b9RMow_1kwlBGY2b1uu3-gtCN4eAjuwbqK7DKwGNJkLnNYKQ5Uh0jSI9CNkI2Qxet97S1odByOa7kA1Wt--v2WP-KmQFeEMHNPp5GOEFIY5-ttqJz1KUiagq4oQPp5OQJ3h8-mN5Kqfh8_kBlLUQ8Bt2a30hKy6aHESerKcT8sgnOUQKc0fwBKLgVwCAPhh0Gowj6IUsuRdRHCEgzcFBKtIjiOL8D87pGTRaJBQp52Tn1fhRnu3kIGT5BUHZ6KELKo7g3UqX4rYRJj-hI8bVzow23aVZXlTQm1e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