diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-12 01:48:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-12 01:48:56 +0000 |
commit | fadb53b351977ca7f99a9a613596cba6531979a3 (patch) | |
tree | 62eb086a53b3804a617c98061b19b12fe45b911c /lib/Sema/SemaOverload.cpp | |
parent | 5a5b38f4afaf4f203b96a11ba79890c7cd4cc4b8 (diff) |
Fixes for some more expressions containing function templateids that
should be resolvable, from Faisal Vali!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index bf24b74848..d746c7bb1e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -7490,6 +7490,44 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From, return Matched; } + + + +// Resolve and fix an overloaded expression that +// can be resolved because it identifies a single function +// template specialization +// Last three arguments should only be supplied if Complain = true +ExprResult Sema::ResolveAndFixSingleFunctionTemplateSpecialization( + Expr *SrcExpr, bool DoFunctionPointerConverion, bool Complain, + const SourceRange& OpRangeForComplaining, + QualType DestTypeForComplaining, + unsigned DiagIDForComplaining ) { + + assert(SrcExpr->getType() == Context.OverloadTy); + + DeclAccessPair Found; + Expr* SingleFunctionExpression = 0; + if (FunctionDecl* Fn = ResolveSingleFunctionTemplateSpecialization( + SrcExpr, false, // false -> Complain + &Found)) { + if (!DiagnoseUseOfDecl(Fn, SrcExpr->getSourceRange().getBegin())) { + // mark the expression as resolved to Fn + SingleFunctionExpression = FixOverloadedFunctionReference(SrcExpr, + Found, Fn); + if (DoFunctionPointerConverion) + DefaultFunctionArrayLvalueConversion(SingleFunctionExpression); + } + } + if (!SingleFunctionExpression && Complain) { + OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression; + Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining) + << oe->getName() << DestTypeForComplaining << OpRangeForComplaining + << oe->getQualifierLoc().getSourceRange(); + NoteAllOverloadCandidates(SrcExpr); + } + return SingleFunctionExpression; +} + /// \brief Add a single candidate to the overload set. static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, |