This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Add a note to point to the inaccessible destructor.
AbandonedPublic

Authored by davide on Jul 26 2015, 1:30 PM.

Details

Reviewers
nlewycky
rsmith
Summary

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.

Diff Detail

Event Timeline

davide updated this revision to Diff 30666.Jul 26 2015, 1:30 PM
davide retitled this revision from to [Sema] Add a note to point to the inaccessible destructor..
davide updated this object.
davide added reviewers: nlewycky, rsmith.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: cfe-commits.
rsmith added inline comments.Jul 26 2015, 2:01 PM
lib/Sema/SemaDeclCXX.cpp
5575–5581

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).

davide added a subscriber: davide.Jul 26 2015, 3:03 PM

Thanks for the review. Are you OK with un-statitcize
DiagnoseAccessPath so that SemaDeclCXX can call it -- or do you prefer
to introduce a wrapper?

rsmith edited edge metadata.Jul 27 2015, 4:56 PM

I would suggest adding a bool Diagnose parameter to CheckAccess and to Sema::isSpecialMemberAccessibleForDeletion.

davide abandoned this revision.Sep 9 2016, 1:44 PM