<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73782>73782</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Diagnotic message about private members is printed for namespace scope entities
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Endilll
</td>
</tr>
</table>
<pre>
Consider the test for CWG16 (shortened to remove unrelated diagnostic):
```cpp
namespace dr16 { // dr16: yes
class A { // expected-note {{here}}
void f(); // expected-note {{here}}
friend class C;
};
class B : A {}; // expected-note 3{{here}}
class C : B {
void g() {
A::f(); // expected-error {{private member}} expected-error {{private base}}
}
};
}
```
Clang post-17 trunk output reads the following:
```
<source>:9:7: error: 'A' is a private member of 'dr16::A'
9 | A::f(); // expected-error {{private member}} expected-error {{private base}}
| ^
<source>:6:13: note: constrained by implicitly private inheritance here
6 | class B : A {}; // expected-note 3{{here}}
| ^
<source>:2:9: note: member is declared here
2 | class A { // expected-note {{here}}
| ^
<source>:9:10: error: cannot cast 'dr16::C' to its private base class 'dr16::A'
9 | A::f(); // expected-error {{private member}} expected-error {{private base}}
| ^
<source>:6:13: note: implicitly declared private here
6 | class B : A {}; // expected-note 3{{here}}
| ^
```
I don't think statements `'A' is a private member of 'dr16::A'` and `member is declared here` (pointing to `class A`) make sense in isolation, and those are not the messages we should see here. I think we should be saying something along the lines of `'A' is a private base class of 'dr16::B'`, and the note shouldn't be printed. Another option is to base error message off `base class subobject` term, which may or may not make the note about where the member is declared useful.
Good first issue?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVt1uozgUfhrn5qgRmCQkF7kgyWQ0T7DXxpwEb42NfA7t5u1XNjQ_7bTaWY20K6Gmxvb5fs4HWBGZs0PciuVOLA8zNXDrw_aba4y1dlb75rLde0emwQDcIjASw8kH2P_xPV-BkGtqfWB02AB7CNj5F4T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