aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-14 20:00:47 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-14 20:00:47 +0000
commit1282029f3d37f482bbba3c38ea9da17a78d11d40 (patch)
tree571056bc540ad53f9df86da01bf106564b3bfac1 /lib/Sema/SemaTemplateDeduction.cpp
parenta7c5b0832cc78efa899463b8faa573a1473d53d2 (diff)
Tighten up checking of non-dependent arguments as part of template
argument deduction. This fixes the new test case (since partial ordering does not have a "verify the results of deduction" step), and will allow failed template argument deductions to return more quickly for, e.g., matching class template partial specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 1ade29869d..d9d1483c67 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -39,7 +39,11 @@ namespace clang {
/// \brief Within template argument deduction from a function call,
/// we are matching in a case where we can perform template argument
/// deduction from a template-id of a derived class of the argument type.
- TDF_DerivedClass = 0x04
+ TDF_DerivedClass = 0x04,
+ /// \brief Allow non-dependent types to differ, e.g., when performing
+ /// template argument deduction from a function call where conversions
+ /// may apply.
+ TDF_SkipNonDependent = 0x08
};
}
@@ -378,8 +382,14 @@ DeduceTemplateArguments(ASTContext &Context,
}
// If the parameter type is not dependent, there is nothing to deduce.
- if (!Param->isDependentType())
+ if (!Param->isDependentType()) {
+ if (!(TDF & TDF_SkipNonDependent) && Param != Arg) {
+
+ return Sema::TDK_NonDeducedMismatch;
+ }
+
return Sema::TDK_Success;
+ }
// C++ [temp.deduct.type]p9:
// A template type argument T, a template template argument TT or a
@@ -1368,7 +1378,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
// In general, the deduction process attempts to find template argument
// values that will make the deduced A identical to A (after the type A
// is transformed as described above). [...]
- unsigned TDF = 0;
+ unsigned TDF = TDF_SkipNonDependent;
// - If the original P is a reference type, the deduced A (i.e., the
// type referred to by the reference) can be more cv-qualified than