[cfe-commits] r81885 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/SemaTemplate/constructor-template.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 15 11:26:14 PDT 2009


Author: dgregor
Date: Tue Sep 15 13:26:13 2009
New Revision: 81885

URL: http://llvm.org/viewvc/llvm-project?rev=81885&view=rev
Log:
Add an assertion and a test case, in a fruitless attempt to track down an existing bug

Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/SemaTemplate/constructor-template.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=81885&r1=81884&r2=81885&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Sep 15 13:26:13 2009
@@ -1244,6 +1244,9 @@
   if (!Specialization)
     return TDK_SubstitutionFailure;
 
+  assert(Specialization->getPrimaryTemplate()->getCanonicalDecl() == 
+         FunctionTemplate->getCanonicalDecl());
+  
   // If the template argument list is owned by the function template
   // specialization, release it.
   if (Specialization->getTemplateSpecializationArgs() == DeducedArgumentList)

Modified: cfe/trunk/test/SemaTemplate/constructor-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/constructor-template.cpp?rev=81885&r1=81884&r2=81885&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/constructor-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/constructor-template.cpp Tue Sep 15 13:26:13 2009
@@ -26,3 +26,23 @@
   
   X0 x0g(f, &i); // expected-error{{no matching constructor}}
 }
+
+template<typename T>
+struct X1 {
+  X1(const X1&);
+  template<typename U> X1(const X1<U>&);
+};
+
+template<typename T>
+struct Outer {
+  typedef X1<T> A;
+  
+  A alloc;
+  
+  explicit Outer(const A& a) : alloc(a) { }
+};
+
+void test_X1(X1<int> xi) {
+  Outer<int> oi(xi);
+  Outer<float> of(xi);
+}





More information about the cfe-commits mailing list