This patch reduces duplication in the template argument deduction code
for handling deduction from initializer lists in a function call. This
extends the fix for PR12119 to also apply to the case where the
corresponding parameter is a trailing parameter pack.
Details
Diff Detail
Event Timeline
lib/Sema/SemaTemplateDeduction.cpp | ||
---|---|---|
3201 | Maybe just make this return the TemplateDeductionResult? You -- almost, see below -- always treat a return of false from here and a return of true with Result == TDK_Success the same (which makes sense, because they mean the same thing -- deduction succeeded). | |
3432–3433 | Is this really right? It seems to cause an accepts-invalid on this: #include <initializer_list> #include <tuple> template<typename ...T> void f(std::tuple<T...> a, T ...b); void g() { f(std::make_tuple(1, 2), {}, 3.0); } Should this instead be ignoring this P/A pair and carrying on to the next, as we do if deduction succeeds? (This is a pre-existing bug, but it's the only barrier to the cleanup I suggested above.) |
The additional bug appears to affect more than just the part being changed here. I think it would make sense to leave that change for a separate commit (and get the clean up done there).
lib/Sema/SemaTemplateDeduction.cpp | ||
---|---|---|
3432–3433 | This seems to be a larger issue having to do with undeduced contexts and trailing parameter packs. #include <initializer_list> #include <tuple> void f(); void f(bool); typedef void (*fptype)(); struct Func { operator fptype(); } func; template<typename ...T> void f(std::tuple<T...> a, T ...b); void g() { f(std::make_tuple(fptype(), fptype()), f, func); } // Clang and GCC accept void g1() { f(std::make_tuple(fptype(), fptype()), func, f); } // GCC accepts, Clang rejects |
Maybe just make this return the TemplateDeductionResult? You -- almost, see below -- always treat a return of false from here and a return of true with Result == TDK_Success the same (which makes sense, because they mean the same thing -- deduction succeeded).