Don't perform ADL when looking up operator=; there is no non-member form of

that function, and apart from being slow, this is unnecessary: ADL can trigger
instantiations that are not permitted here. The standard isn't *completely*
clear here, but this seems like the intent, and in any case this approach is
permitted by [temp.inst]p7.

llvm-svn: 218330
This commit is contained in:
Richard Smith
2014-09-23 20:31:39 +00:00
parent dedef3325f
commit 0daabd7ebe
4 changed files with 24 additions and 9 deletions

View File

@@ -11031,10 +11031,13 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
// Add operator candidates that are member functions.
AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
// Add candidates from ADL.
AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
/*ExplicitTemplateArgs*/ nullptr,
CandidateSet);
// Add candidates from ADL. Per [over.match.oper]p2, this lookup is not
// performed for an assignment operator (nor for operator[] nor operator->,
// which don't get here).
if (Opc != BO_Assign)
AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
/*ExplicitTemplateArgs*/ nullptr,
CandidateSet);
// Add builtin operator candidates.
AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);