summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-24 05:53:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-24 05:53:11 +0000
commit9771f500f29235d79276c30d784859572aefc764 (patch)
treea7a342057212d55634a4993401d4af195ad21d18
parent2fb6b0f2baf4b1da6201035f53ca7e471b9d4c1e (diff)
downloadbcm5719-llvm-9771f500f29235d79276c30d784859572aefc764.tar.gz
bcm5719-llvm-9771f500f29235d79276c30d784859572aefc764.zip
PR42362: Fix auto deduction of template parameter packs from
type-dependent argument packs. We need to strip off the PackExpansionExpr to get the real (dependent) type rather than an opaque DependentTy. llvm-svn: 364165
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp5
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp15
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7b0a3a3e094..49ba771379e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -6323,9 +6323,12 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// the type is dependent, in order to check the types of non-type template
// arguments line up properly in partial ordering.
Optional<unsigned> Depth = Param->getDepth() + 1;
+ Expr *DeductionArg = Arg;
+ if (auto *PE = dyn_cast<PackExpansionExpr>(DeductionArg))
+ DeductionArg = PE->getPattern();
if (DeduceAutoType(
Context.getTrivialTypeSourceInfo(ParamType, Param->getLocation()),
- Arg, ParamType, Depth) == DAR_Failed) {
+ DeductionArg, ParamType, Depth) == DAR_Failed) {
Diag(Arg->getExprLoc(),
diag::err_non_type_template_parm_type_deduction_failure)
<< Param->getDeclName() << Param->getType() << Arg->getType()
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
index b887c7f47d3..d73a88777d0 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -378,3 +378,18 @@ template <class T> struct M {
}
};
}
+
+namespace PR42362 {
+ template<auto ...A> struct X { struct Y; void f(int...[A]); };
+ template<auto ...A> struct X<A...>::Y {};
+ template<auto ...A> void X<A...>::f(int...[A]) {}
+ void f() { X<1, 2>::Y y; X<1, 2>().f(0, 0); }
+
+ template<typename, auto...> struct Y;
+ template<auto ...A> struct Y<int, A...> {};
+ Y<int, 1, 2, 3> y;
+
+ template<auto (&...F)()> struct Z { struct Q; };
+ template<auto (&...F)()> struct Z<F...>::Q {};
+ Z<f, f, f>::Q q;
+}
OpenPOWER on IntegriCloud