From: Richard Smith Date: Fri, 30 Dec 2016 04:32:02 +0000 (+0000) Subject: Remove bogus assertion and add testcase that triggers it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd7e95640dcd0fa6009b176bc47a96b70a231a23;p=clang Remove bogus assertion and add testcase that triggers it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290743 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index d10b0c9a1c..3657886b10 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -380,8 +380,6 @@ static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument( Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, Expr *Value, TemplateDeductionInfo &Info, SmallVectorImpl &Deduced) { - assert((Value->isTypeDependent() || Value->isValueDependent()) && - "Expression template argument must be type- or value-dependent."); return DeduceNonTypeTemplateArgument(S, TemplateParams, NTTP, DeducedTemplateArgument(Value), Value->getType(), Info, Deduced); @@ -4363,6 +4361,10 @@ static bool isAtLeastAsSpecializedAs(Sema &S, if (Deduced[ArgIdx].isNull()) break; + // FIXME: We fail to implement [temp.deduct.type]p1 along this path. We need + // to substitute the deduced arguments back into the template and check that + // we get the right type. + if (ArgIdx == NumArgs) { // All template arguments were deduced. FT1 is at least as specialized // as FT2. diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index d554176e58..93f11b5657 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -434,3 +434,20 @@ namespace dependent_nested_partial_specialization { }; E::F e1; // expected-note {{instantiation of}} } + +namespace nondependent_default_arg_ordering { + int n, m; + template struct X {}; + template void f(X); // expected-note {{candidate}} + template void f(X); // expected-note {{candidate}} + template void f(X); // expected-note 2{{candidate}} + template class T, typename A, int *B> void f(T); // expected-note 2{{candidate}} + void g() { + // FIXME: The first and second function templates above should be + // considered more specialized than the last two, but during partial + // ordering we fail to check that we actually deduced template arguments + // that make the deduced A identical to A. + X x; f(x); // expected-error {{ambiguous}} + X y; f(y); // expected-error {{ambiguous}} + } +}