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
Differential D11334
[Sema] Call to deleted functions are supposed to be verboten Authored by davide on Jul 18 2015, 9:37 PM.
Details 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 Event TimelineComment Actions I don't spend a lot of time on the internals of clang; but this looks reasonable to me.
| ||||||
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?