aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-29 21:14:36 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-29 21:14:36 +0000
commitfbb6fad63acac2bef36cfa13e0706fa3e2a1ed7d (patch)
tree8ac8312e4c7b6fea13887092cce0413127a0e326 /lib/Sema/SemaTemplateDeduction.cpp
parente24724893a2f9cb1d660b2e1d5b7b8b899aedb3d (diff)
When performing template argument deduction of a function template
against a function type, be sure to check the type of the resulting function template specialization against the desired function type after substituting the deduced/defaulted template arguments. Fixes PR8196. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115086 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 5c77ed6106..f3ffa716f1 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1865,10 +1865,20 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
Deduced, 0))
return Result;
}
-
- return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
- NumExplicitlySpecified,
- Specialization, Info);
+
+ if (TemplateDeductionResult Result
+ = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
+ NumExplicitlySpecified,
+ Specialization, Info))
+ return Result;
+
+ // If the requested function type does not match the actual type of the
+ // specialization, template argument deduction fails.
+ if (!ArgFunctionType.isNull() &&
+ !Context.hasSameType(ArgFunctionType, Specialization->getType()))
+ return TDK_NonDeducedMismatch;
+
+ return TDK_Success;
}
/// \brief Deduce template arguments for a templated conversion