summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-04-04 05:10:53 +0000
committerDouglas Gregor <dgregor@apple.com>2012-04-04 05:10:53 +0000
commit0e60cd78cc3c071870bba865663d09c09f184544 (patch)
treeb1c56857f4de66d4d8f85d1e26fd4bbeda287f44 /clang/lib/Sema/SemaTemplateDeduction.cpp
parent34487838bfcb8b498fe91d6349c0f0acd397e8a9 (diff)
downloadbcm5719-llvm-0e60cd78cc3c071870bba865663d09c09f184544.tar.gz
bcm5719-llvm-0e60cd78cc3c071870bba865663d09c09f184544.zip
When performing template argument deduction for an initializer list,
be sure to perform the argument type adjustments in [temp.deduct.call]p2, e.g., array decay. And, when performing these deductions in the context of 'auto', make sure that we're deducing the P' in std::initializer_list<P'> rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. llvm-svn: 153998
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index bc6138d559f..b4486333812 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2935,8 +2935,12 @@ DeduceTemplateArgumentByListElement(Sema &S,
}
// For all other cases, just match by type.
+ QualType ArgType = Arg->getType();
+ if (AdjustFunctionParmAndArgTypesForDeduction(S, TemplateParams, ParamType,
+ ArgType, Arg, TDF))
+ return Sema::TDK_FailedOverloadResolution;
return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams, ParamType,
- Arg->getType(), Info, Deduced, TDF);
+ ArgType, Info, Deduced, TDF);
}
/// \brief Perform template argument deduction from a function call
@@ -3494,22 +3498,24 @@ Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *&Init,
Deduced.resize(1);
QualType InitType = Init->getType();
unsigned TDF = 0;
- if (AdjustFunctionParmAndArgTypesForDeduction(*this, &TemplateParams,
- FuncParam, InitType, Init,
- TDF))
- return DAR_Failed;
TemplateDeductionInfo Info(Context, Loc);
InitListExpr * InitList = dyn_cast<InitListExpr>(Init);
if (InitList) {
for (unsigned i = 0, e = InitList->getNumInits(); i < e; ++i) {
- if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
- InitList->getInit(i)->getType(),
- Info, Deduced, TDF))
+ if (DeduceTemplateArgumentByListElement(*this, &TemplateParams,
+ TemplArg,
+ InitList->getInit(i),
+ Info, Deduced, TDF))
return DAR_Failed;
}
} else {
+ if (AdjustFunctionParmAndArgTypesForDeduction(*this, &TemplateParams,
+ FuncParam, InitType, Init,
+ TDF))
+ return DAR_Failed;
+
if (DeduceTemplateArgumentsByTypeMatch(*this, &TemplateParams, FuncParam,
InitType, Info, Deduced, TDF))
return DAR_Failed;
OpenPOWER on IntegriCloud