summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-08 18:13:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-08 18:13:28 +0000
commit02eb4835ce7daa66d27d6422aa6dea343dc52895 (patch)
tree681bfb32951336bfb09ef1ca1fad5dd9b21e127e /clang/lib/Sema
parent3626a5cac2edf659c68e181e45ea77ebcb981489 (diff)
downloadbcm5719-llvm-02eb4835ce7daa66d27d6422aa6dea343dc52895.tar.gz
bcm5719-llvm-02eb4835ce7daa66d27d6422aa6dea343dc52895.zip
When template argument deduction fails because the call had too
many/too few arguments, use the same diagnostic we use for arity mismatches in non-templates (but note that it's a function template). llvm-svn: 103341
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index c08095fae4e..93e9c7f4e79 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -5056,16 +5056,21 @@ void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand,
unsigned MinParams = Fn->getMinRequiredArguments();
// at least / at most / exactly
+ // FIXME: variadic templates "at most" should account for parameter packs
unsigned mode, modeCount;
if (NumFormalArgs < MinParams) {
- assert(Cand->FailureKind == ovl_fail_too_few_arguments);
+ assert((Cand->FailureKind == ovl_fail_too_few_arguments) ||
+ (Cand->FailureKind == ovl_fail_bad_deduction &&
+ Cand->DeductionFailure.Result == Sema::TDK_TooFewArguments));
if (MinParams != FnTy->getNumArgs() || FnTy->isVariadic())
mode = 0; // "at least"
else
mode = 2; // "exactly"
modeCount = MinParams;
} else {
- assert(Cand->FailureKind == ovl_fail_too_many_arguments);
+ assert((Cand->FailureKind == ovl_fail_too_many_arguments) ||
+ (Cand->FailureKind == ovl_fail_bad_deduction &&
+ Cand->DeductionFailure.Result == Sema::TDK_TooManyArguments));
if (MinParams != FnTy->getNumArgs())
mode = 1; // "at most"
else
@@ -5077,7 +5082,8 @@ void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand,
OverloadCandidateKind FnKind = ClassifyOverloadCandidate(S, Fn, Description);
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
- << (unsigned) FnKind << Description << mode << modeCount << NumFormalArgs;
+ << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != 0) << mode
+ << modeCount << NumFormalArgs;
}
/// Diagnose a failed template-argument deduction.
@@ -5120,14 +5126,17 @@ void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand,
<< *Cand->DeductionFailure.getSecondArg();
return;
}
+
+ case Sema::TDK_TooManyArguments:
+ case Sema::TDK_TooFewArguments:
+ DiagnoseArityMismatch(S, Cand, NumArgs);
+ return;
// TODO: diagnose these individually, then kill off
// note_ovl_candidate_bad_deduction, which is uselessly vague.
case Sema::TDK_InstantiationDepth:
case Sema::TDK_SubstitutionFailure:
case Sema::TDK_NonDeducedMismatch:
- case Sema::TDK_TooManyArguments:
- case Sema::TDK_TooFewArguments:
case Sema::TDK_InvalidExplicitArguments:
case Sema::TDK_FailedOverloadResolution:
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_deduction);
OpenPOWER on IntegriCloud