From 31fae894977943930d22d02c9663ca18c8bc1e68 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 15 Sep 2009 18:26:13 +0000 Subject: [PATCH] Add an assertion and a test case, in a fruitless attempt to track down an existing bug llvm-svn: 81885 --- clang/lib/Sema/SemaTemplateDeduction.cpp | 3 +++ .../SemaTemplate/constructor-template.cpp | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index da64b55d8232..24246e57348e 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1244,6 +1244,9 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, 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) diff --git a/clang/test/SemaTemplate/constructor-template.cpp b/clang/test/SemaTemplate/constructor-template.cpp index 5a2630c2cff8..41b0d29cf83a 100644 --- a/clang/test/SemaTemplate/constructor-template.cpp +++ b/clang/test/SemaTemplate/constructor-template.cpp @@ -26,3 +26,23 @@ void test_X0(int i, float f) { X0 x0g(f, &i); // expected-error{{no matching constructor}} } + +template +struct X1 { + X1(const X1&); + template X1(const X1&); +}; + +template +struct Outer { + typedef X1 A; + + A alloc; + + explicit Outer(const A& a) : alloc(a) { } +}; + +void test_X1(X1 xi) { + Outer oi(xi); + Outer of(xi); +}