Fix PR24694 (CWG1591): Deducing array bound and element type from initializer list
authorFaisal Vali <faisalv@yahoo.com>
Thu, 10 Dec 2015 05:36:39 +0000 (05:36 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Thu, 10 Dec 2015 05:36:39 +0000 (05:36 +0000)
commitf6dfdb361f87b7d7ba0f57ddbb2d38eab157c606
treea6c8c3dec781cf503522540d290d6aadb0c151ef
parentf170ba08af4690de355822f35714ed72da4e4814
Fix PR24694 (CWG1591): Deducing array bound and element type from initializer list
https://llvm.org/bugs/show_bug.cgi?id=24694
http://wg21.link/cwg1591

Teach DeduceFromInitializerList in SemaTemplateDeduction.cpp to deduce against array (constant and dependent sized) parameters (really, reference to arrays since they don't decay to pointers), by checking if the template parameter is either one of those kinds of arrays, and if so, deducing each initializer list element against the element type, and then deducing the array bound if needed.

In brief, this patch enables the following code:
template<class T, int N> int *f(T (&&)[N]);
int *ip = f({1, 2, 3});

llvm-svn: 255221
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/drs/dr15xx.cpp