<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121258>121258</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-trunk rejects valid friend declaration of private base class with very confusing diagnostic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wangbo15
</td>
</tr>
</table>
<pre>
The following code is rejected by clang-trunk:
```c++
struct payload {};
struct base: private payload {
};
struct derived: base {
friend class payload;
};
```
The diagnostic is hard to understand. It seems the compiler treats the private inheritance statement as a member declaration or something else here:
```c++
<source>:7:18: error: 'payload' is a private member of 'payload'
7 | friend class payload;
| ^
<source>:3:14: note: constrained by private inheritance here
3 | struct base: private payload {
| ^~~~~~~~~~~~~~~
<source>:1:8: note: member is declared here
1 | struct payload {};
| ^
1 error generated.
```
GCC and MSVC both accept it.
Please see [https://godbolt.org/z/4da5TbvYe](https://godbolt.org/z/4da5TbvYe)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMlEFv6zYMxz-NciEa2FJc2wcfkvRl2GHAgD0M2JG2GFubLAUSnaI77LMPsp22eS0eaghIYJH0j3_9RYzR9I6oEcVBFE8bnHjwoXlG17c-Lzat1y_N94Hg7K31z8b10HlNYCIE-ps6Jg3tC3QWXf_AYXL_CLUX2bwes2V1Qh7SyvaRw9QxXPDFetQgyoMon4Q6LAnrbouRhNrDJZgrMt1FZ_tPEjQFcyWdclLuGggAcA6GnE50Md7qrNmvZW6US8nUqjbYOx_ZdKnNAYMG9jA5TSEyOr2FXxki0RiBB4LOjxdjKQAHQl7e3diNGygYRtcRREamkRwDRkAYaWwpgKbOYkA23oEPEP1IPCSZyUaCgQL9TFChjtFPoSOhvgm1L4Xa51USgkLwIf0Rsrw1LsvUD77CrQT-fB-0aleCKI_wcxXn7TlOFN8-4qiEs0sUzvN8pp13kQMat9jmM5nmlpfSai79JVvckfx393zkyoXaV--xViVMXI-D9HuM_D3GZ959-_j6LGrkyylAT44CMuntR7_9cjwCOg2__fHnEVrPA2DX0YXB8HaJ-N1SMnUkAlEcBuZLTI6QJyFPvdett7z1oRfy9K-Qp53G4nt7_YtE8SRk9fVwWW90o3StatxQk5eqUGVZ5fVmaLLi_JhVeV1gWefUyrpD1PpcPXbY5m1eb0wjM7nLpayyWipVb3GXl1Q-FgrbKquIxC6jEY3dWnsd0-c3JsaJmlzmsqg2FluycR5BUjp6hnlXSJkmUmhS0kM79VHsMmsix7cybNhSc3ybPutUinBFa_TNuneX7PxqoXlaLLZ-NjzAlcJLsuh5iukGvs2BzRRs84OWhoep3XZ-FPKUeNafh0vwiUDI09xFFPK0tnlt5P8BAAD__1VysuM">