This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Call to deleted functions are supposed to be verboten
ClosedPublic

Authored by davide on Jul 18 2015, 9:37 PM.

Details

Summary

I originally tried to fix this in SemaExpr (ActOnCallExpr), putting this check just before BuildCallToMemberFunction() call, but eventaully convinced myself SemaOverload should be the right place to fix.

Thanks,

Davide

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 30105.Jul 18 2015, 9:37 PM
davide retitled this revision from to [Sema] Call to deleted functions are supposed to be verboten.
davide updated this object.
davide added reviewers: rsmith, mclow.lists.
davide added a subscriber: cfe-commits.
mclow.lists edited edge metadata.Jul 21 2015, 8:02 AM

I don't spend a lot of time on the internals of clang; but this looks reasonable to me.

davide updated this revision to Diff 30288.Jul 21 2015, 2:38 PM
davide edited edge metadata.

Addressing comments.

rsmith added inline comments.Jul 21 2015, 2:59 PM
lib/Sema/SemaOverload.cpp
11608 ↗(On Diff #30288)

This check should happen when we build the MemberExpr, not when we use it. It looks like the bug is in Sema::BuildMemberReferenceExpr, at around line 1050 of SemaExprMember.cpp:

bool ShouldCheckUse = true;
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(MemberDecl)) {
  // Don't diagnose the use of a virtual member function unless it's
  // explicitly qualified.
  if (MD->isVirtual() && !SS.isSet())
    ShouldCheckUse = false;
}

// Check the use of this member.
if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc))
  return ExprError();

This is wrong: we should DiagnoseUseOfDecl (including diagnosing the use of a deleted function) even for a virtual function. Which tests fail if we unconditionally DiagnoseUseOfDecl here?

This revision was automatically updated to reflect the committed changes.