r290743 - Remove bogus assertion and add testcase that triggers it.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 29 20:32:02 PST 2016


Author: rsmith
Date: Thu Dec 29 22:32:02 2016
New Revision: 290743

URL: http://llvm.org/viewvc/llvm-project?rev=290743&view=rev
Log:
Remove bogus assertion and add testcase that triggers it.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290743&r1=290742&r2=290743&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Dec 29 22:32:02 2016
@@ -380,8 +380,6 @@ static Sema::TemplateDeductionResult Ded
     Sema &S, TemplateParameterList *TemplateParams,
     NonTypeTemplateParmDecl *NTTP, Expr *Value, TemplateDeductionInfo &Info,
     SmallVectorImpl<DeducedTemplateArgument> &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(Sem
     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.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=290743&r1=290742&r2=290743&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Dec 29 22:32:02 2016
@@ -434,3 +434,20 @@ namespace dependent_nested_partial_speci
   };
   E<int>::F<int, 0> e1; // expected-note {{instantiation of}}
 }
+
+namespace nondependent_default_arg_ordering {
+  int n, m;
+  template<typename A, A B = &n> struct X {};
+  template<typename A> void f(X<A>); // expected-note {{candidate}}
+  template<typename A> void f(X<A, &m>); // expected-note {{candidate}}
+  template<typename A, A B> void f(X<A, B>); // expected-note 2{{candidate}}
+  template<template<typename U, U> class T, typename A, int *B> void f(T<A, B>); // 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<int *, &n> x; f(x); // expected-error {{ambiguous}}
+    X<int *, &m> y; f(y); // expected-error {{ambiguous}}
+  }
+}




More information about the cfe-commits mailing list