summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-30 22:13:51 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-30 22:13:51 +0000
commit42909754f60ef1bde47ef94f372d0d05f9a5da40 (patch)
tree3c38b8fa08194bca6f8463b77c04cd6dbb334ea1
parentb633d7a6659bd80e25d4454636bdeb3485009829 (diff)
downloadbcm5719-llvm-42909754f60ef1bde47ef94f372d0d05f9a5da40.tar.gz
bcm5719-llvm-42909754f60ef1bde47ef94f372d0d05f9a5da40.zip
Improve template argument deduction in the case where the parameter
type is a template-id (e.g., basic_ostream<CharT, Traits>) and the argument type is a class that has a derived class matching the parameter type. Previously, we were giving up on template argument deduction too early. llvm-svn: 83177
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp8
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp4
2 files changed, 4 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 64b7f8b140e..b981389d1d1 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -651,8 +651,7 @@ DeduceTemplateArguments(ASTContext &Context,
= DeduceTemplateArguments(Context, TemplateParams, SpecParam, Arg,
Info, Deduced);
- if (Result && (TDF & TDF_DerivedClass) &&
- Result != Sema::TDK_Inconsistent) {
+ if (Result && (TDF & TDF_DerivedClass)) {
// C++ [temp.deduct.call]p3b3:
// If P is a class, and P has the form template-id, then A can be a
// derived class of the deduced A. Likewise, if P is a pointer to a
@@ -690,11 +689,6 @@ DeduceTemplateArguments(ASTContext &Context,
// note that we had some success.
if (BaseResult == Sema::TDK_Success)
Successful = true;
- // If deduction against this base resulted in an inconsistent
- // set of deduced template arguments, template argument
- // deduction fails.
- else if (BaseResult == Sema::TDK_Inconsistent)
- return BaseResult;
}
// Visit base classes
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
index 596427adf9e..dbe2ff3e18f 100644
--- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
@@ -66,6 +66,7 @@ template<typename T, int I> struct C { };
struct D : public C<int, 1> { };
struct E : public D { };
struct F : A<float> { };
+struct G : A<float>, C<int, 1> { };
template<typename T, int I>
C<T, I> *f4a(const C<T, I>&);
@@ -75,12 +76,13 @@ template<typename T, int I>
C<T, I> *f4c(C<T, I>*);
int *f4c(...);
-void test_f4(D d, E e, F f) {
+void test_f4(D d, E e, F f, G g) {
C<int, 1> *ci1a = f4a(d);
C<int, 1> *ci2a = f4a(e);
C<int, 1> *ci1b = f4b(d);
C<int, 1> *ci2b = f4b(e);
C<int, 1> *ci1c = f4c(&d);
C<int, 1> *ci2c = f4c(&e);
+ C<int, 1> *ci3c = f4c(&g);
int *ip1 = f4c(&f);
}
OpenPOWER on IntegriCloud