On Thu, Dec 6, 2012 at 7:44 AM, Richard Smith <[email protected]>wrote:
> Author: rsmith > Date: Thu Dec 6 00:44:44 2012 > New Revision: 169475 > > URL: http://llvm.org/viewvc/llvm-project?rev=169475&view=rev > Log: > Fix http://stackoverflow.com/questions/13521163 > > Just curious: did you stumble on it by accident or are you actively watching the `clang` tag ? In any case it's great to see that a bug that did not even hit the bug database got fixed! -- Matthieu > Don't require that, during template deduction, a template specialization > type > as a function parameter has at least as many template arguments as one > used in > a function argument (not even if the argument has been resolved to an exact > type); the additional parameters might be provided by default template > arguments in the template. We don't need this check, since we now implement > [temp.deduct.call]p4 with an additional check after deduction. > > Modified: > cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp > > cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp > > Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=169475&r1=169474&r2=169475&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original) > +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 6 00:44:44 2012 > @@ -130,8 +130,7 @@ > const TemplateArgument *Params, unsigned > NumParams, > const TemplateArgument *Args, unsigned NumArgs, > TemplateDeductionInfo &Info, > - SmallVectorImpl<DeducedTemplateArgument> &Deduced, > - bool NumberOfArgumentsMustMatch = true); > + SmallVectorImpl<DeducedTemplateArgument> > &Deduced); > > /// \brief If the given expression is of a form that permits the deduction > /// of a non-type template parameter, return the declaration of that > @@ -482,8 +481,7 @@ > return DeduceTemplateArguments(S, TemplateParams, > Param->getArgs(), Param->getNumArgs(), > SpecArg->getArgs(), > SpecArg->getNumArgs(), > - Info, Deduced, > - /*NumberOfArgumentsMustMatch=*/false); > + Info, Deduced); > } > > // If the argument type is a class template specialization, we > @@ -1749,8 +1747,7 @@ > const TemplateArgument *Params, unsigned > NumParams, > const TemplateArgument *Args, unsigned NumArgs, > TemplateDeductionInfo &Info, > - SmallVectorImpl<DeducedTemplateArgument> &Deduced, > - bool NumberOfArgumentsMustMatch) { > + SmallVectorImpl<DeducedTemplateArgument> > &Deduced) { > // C++0x [temp.deduct.type]p9: > // If the template argument list of P contains a pack expansion that > is not > // the last template argument, the entire template argument list is a > @@ -1770,8 +1767,7 @@ > > // Check whether we have enough arguments. > if (!hasTemplateArgumentForDeduction(Args, ArgIdx, NumArgs)) > - return NumberOfArgumentsMustMatch? Sema::TDK_NonDeducedMismatch > - : Sema::TDK_Success; > + return Sema::TDK_Success; > > if (Args[ArgIdx].isPackExpansion()) { > // FIXME: We follow the logic of C++0x [temp.deduct.type]p22 here, > @@ -1867,11 +1863,6 @@ > return Result; > } > > - // If there is an argument remaining, then we had too many arguments. > - if (NumberOfArgumentsMustMatch && > - hasTemplateArgumentForDeduction(Args, ArgIdx, NumArgs)) > - return Sema::TDK_NonDeducedMismatch; > - > return Sema::TDK_Success; > } > > > Modified: > cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp?rev=169475&r1=169474&r2=169475&view=diff > > ============================================================================== > --- > cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp > (original) > +++ > cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp > Thu Dec 6 00:44:44 2012 > @@ -53,3 +53,16 @@ > tuple<unsigned_c<1>, unsigned_c<2>, unsigned_c<3>> > >::value? 1 : -1]; > } > + > +namespace DeduceWithDefaultArgs { > + template<template<typename...> class Container> void f(Container<int>); > // expected-note {{substitution failure [with Container = X]}} > + template<typename, typename = int> struct X {}; > + void g() { > + // OK, use default argument for the second template parameter. > + f(X<int>{}); > + f(X<int, int>{}); > + > + // Not OK. > + f(X<int, double>{}); // expected-error {{no matching function for > call to 'f'}} > + } > +} > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
