From ca4686dc380fa801c114433d46c0cdfbeac3c996 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 4 Jan 2011 23:35:54 +0000 Subject: Improve our handling of non-type template parameters in partial specializations. We weren't dealing with any of the cases where the type of the non-type template argument differs from the type of the corresponding template parameter in the primary template. We would think that the template parameter in the partial specialization was not deducible (and warn about it, incorrectly), then fail to convert a deduced parameter to the type of the template parameter in the partial specialization (which may involve truncation, among other things). Fixes PR8905. llvm-svn: 122851 --- clang/lib/Sema/SemaTemplate.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaTemplate.cpp') diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 1835899e80b..419f59d5886 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2160,7 +2160,7 @@ Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, /// template parameter. bool Sema::CheckTemplateArgument(NamedDecl *Param, const TemplateArgumentLoc &Arg, - TemplateDecl *Template, + NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, llvm::SmallVectorImpl &Converted, @@ -3940,6 +3940,10 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, // We can have a pack expansion of any of the bullets below. if (PackExpansionExpr *Expansion = dyn_cast(ArgExpr)) ArgExpr = Expansion->getPattern(); + + // Strip off any implicit casts we added as part of type checking. + while (ImplicitCastExpr *ICE = dyn_cast(ArgExpr)) + ArgExpr = ICE->getSubExpr(); // C++ [temp.class.spec]p8: // A non-type argument is non-specialized if it is the name of a @@ -3950,7 +3954,7 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, // specialized non-type arguments, so skip any non-specialized // arguments. if (DeclRefExpr *DRE = dyn_cast(ArgExpr)) - if (llvm::isa(DRE->getDecl())) + if (isa(DRE->getDecl())) continue; // C++ [temp.class.spec]p9: -- cgit v1.2.3