summaryrefslogtreecommitdiffstats
path: root/clang/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
commit4ed49f375d6faee8c11a1324f1b6df845f12566e (patch)
tree6f00d7e7b9076f141953494d00e0edca3b659214 /clang/lib/Sema/SemaTemplateDeduction.cpp
parentdb2732ac42a367ecf61614c8344cc39ed250c17d (diff)
downloadbcm5719-llvm-4ed49f375d6faee8c11a1324f1b6df845f12566e.tar.gz
bcm5719-llvm-4ed49f375d6faee8c11a1324f1b6df845f12566e.zip
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. llvm-svn: 115086
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 5c77ed61060..f3ffa716f1b 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud