This is an attempt to fix a FIXME from a previous commits, and now the testcase in PR24260 emits the following diagnostics:
std.cpp:8:5: error: call to implicitly-deleted default constructor of 'Y'
Y y; ^
std.cpp:5:5: note: default constructor of 'Y' is implicitly deleted because field
'x' has an inaccessible destructor X x; ^
std.cpp:2:3: note: destructor is declared here
~X(); // private ^
1 error generated.
I didn't put the name of the class in the note, because it seems pretty obvious from SourceLoc. I can change that, if needed.
This doesn't seem right: you're producing a note for a destructor no matter which special member function was found to be inaccessible. The best thing to do would be to ask the SemaAccess code to produce the relevant note (see DiagnoseAccessPath); that way you can produce a note that says "declared private here" or whatever else is relevant (which can sometimes be that a virtual base destructor is inaccessible due to a private access path, for instance).