[cfe-commits] r117983 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
Douglas Gregor
dgregor at apple.com
Mon Nov 1 17:02:34 PDT 2010
Author: dgregor
Date: Mon Nov 1 19:02:34 2010
New Revision: 117983
URL: http://llvm.org/viewvc/llvm-project?rev=117983&view=rev
Log:
When performing template argument deduction against a template-id,
only keep deduction results for successful deductions, so that they
can be compared against each other. Fixes PR8462, from Richard Smith!
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=117983&r1=117982&r2=117983&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Nov 1 19:02:34 2010
@@ -721,6 +721,8 @@
llvm::SmallVector<const RecordType *, 8> ToVisit;
ToVisit.push_back(RecordT);
bool Successful = false;
+ llvm::SmallVectorImpl<DeducedTemplateArgument> DeducedOrig(0);
+ DeducedOrig = Deduced;
while (!ToVisit.empty()) {
// Retrieve the next class in the inheritance hierarchy.
const RecordType *NextT = ToVisit.back();
@@ -738,9 +740,14 @@
QualType(NextT, 0), Info, Deduced);
// If template argument deduction for this base was successful,
- // note that we had some success.
- if (BaseResult == Sema::TDK_Success)
+ // note that we had some success. Otherwise, ignore any deductions
+ // from this base class.
+ if (BaseResult == Sema::TDK_Success) {
Successful = true;
+ DeducedOrig = Deduced;
+ }
+ else
+ Deduced = DeducedOrig;
}
// Visit base classes
Modified: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp?rev=117983&r1=117982&r2=117983&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp Mon Nov 1 19:02:34 2010
@@ -101,3 +101,25 @@
C<int, 1> *ci3c = f4c(&g);
int *ip1 = f4c(&f);
}
+
+// PR8462
+namespace N {
+ struct T0;
+ struct T1;
+
+ template<typename X, typename Y> struct B {};
+
+ struct J : B<T0,T0> {};
+ struct K : B<T1,T1> {};
+
+ struct D : J, K {};
+
+ template<typename X, typename Y> void F(B<Y,X>);
+
+ void test()
+ {
+ D d;
+ N::F<T0>(d); // Fails
+ N::F<T1>(d); // OK
+ }
+}
More information about the cfe-commits
mailing list