Support for calling overloaded function call operators (operator())
with function call syntax, e.g.,
Functor f;
f(x, y);
This is the easy part of handling calls to objects of class type
(C++ [over.call.object]). The hard part (coping with conversions from
f to function pointer or reference types) will come later. Nobody uses
that stuff anyway, right? :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59663 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a780012..147b4c8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1291,8 +1291,8 @@
// resolution to pick the function.
if (Ovl) {
OverloadCandidateSet CandidateSet;
- OverloadCandidateSet::iterator Best;
AddOverloadCandidates(Ovl, Args, NumArgs, CandidateSet);
+ OverloadCandidateSet::iterator Best;
switch (BestViableFunction(CandidateSet, Best)) {
case OR_Success:
{
@@ -1327,6 +1327,10 @@
}
}
+ if (getLangOptions().CPlusPlus && Fn->getType()->isRecordType())
+ return BuildCallToObjectOfClassType(Fn, LParenLoc, Args, NumArgs,
+ CommaLocs, RParenLoc);
+
// Promote the function operand.
UsualUnaryConversions(Fn);