When finalizing a function template specialization following template

argument deduction, make sure to check the correctness of deduced template
type arguments (which we had previously skipped) along with other
kinds of template arguments. This fixes part of PR6784, but we're
still swallowing the extension warning about unnamed/local template
arguments.

llvm-svn: 116327
This commit is contained in:
Douglas Gregor 2010-10-12 18:51:08 +00:00
parent 758cb67fcf
commit 6e9cf630f8
2 changed files with 13 additions and 7 deletions

View File

@ -1018,7 +1018,7 @@ FinishTemplateArgumentDeduction(Sema &S,
for (unsigned I = 0, N = Deduced.size(); I != N; ++I) { for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
if (Deduced[I].isNull()) { if (Deduced[I].isNull()) {
Decl *Param Decl *Param
= const_cast<NamedDecl *>( = const_cast<NamedDecl *>(
Partial->getTemplateParameters()->getParam(I)); Partial->getTemplateParameters()->getParam(I));
Info.Param = makeTemplateParameter(Param); Info.Param = makeTemplateParameter(Param);
return Sema::TDK_Incomplete; return Sema::TDK_Incomplete;
@ -1383,13 +1383,10 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
for (unsigned I = 0, N = Deduced.size(); I != N; ++I) { for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
NamedDecl *Param = FunctionTemplate->getTemplateParameters()->getParam(I); NamedDecl *Param = FunctionTemplate->getTemplateParameters()->getParam(I);
if (!Deduced[I].isNull()) { if (!Deduced[I].isNull()) {
if (I < NumExplicitlySpecified || if (I < NumExplicitlySpecified) {
Deduced[I].getKind() == TemplateArgument::Type) {
// We have already fully type-checked and converted this // We have already fully type-checked and converted this
// argument (because it was explicitly-specified) or no // argument, because it was explicitly-specified. Just record the
// additional checking is necessary (because it's a template // presence of this argument.
// type parameter). Just record the presence of this
// parameter.
Builder.Append(Deduced[I]); Builder.Append(Deduced[I]);
continue; continue;
} }

View File

@ -10,3 +10,12 @@ template<typename T> struct B {
}; };
B<function> b; // expected-note{{instantiation of}} B<function> b; // expected-note{{instantiation of}}
template <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}}
enum {e};
void test_f0(int n) {
int i = f0(0, e); // FIXME: We should get a warning here, at least
int vla[n];
f0(0, vla); // expected-error{{no matching function for call to 'f0'}}
}