diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-15 16:51:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-15 16:51:42 +0000 |
commit | 9eea08ba72f8b1e7faf38e43376b9157fc4a2af2 (patch) | |
tree | c70d805a8c43ba0fd59498c30392a5bfc4cff431 | |
parent | 8c12506ea0e9d2500f59c9865ff05ebdbae77f49 (diff) |
Slightly improved template argument deduction for use in partial
ordering, along with another test case for partial ordering of partial
specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81869 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 13 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 3 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp | 16 |
3 files changed, 31 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 28ee7d399f..da64b55d82 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -151,7 +151,18 @@ DeduceNonTypeTemplateArgument(ASTContext &Context, return Sema::TDK_Success; } - // FIXME: Compare the expressions for equality! + if (Deduced[NTTP->getIndex()].getKind() == TemplateArgument::Expression) { + // Compare the expressions for equality + llvm::FoldingSetNodeID ID1, ID2; + Deduced[NTTP->getIndex()].getAsExpr()->Profile(ID1, Context, true); + Value->Profile(ID2, Context, true); + if (ID1 == ID2) + return Sema::TDK_Success; + + // FIXME: Fill in argument mismatch information + return Sema::TDK_NonDeducedMismatch; + } + return Sema::TDK_Success; } diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 1cae45e4f8..87216a072d 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -843,6 +843,9 @@ Sema::InstantiateClassTemplateSpecialization( return true; } + if (ClassTemplateSpec->isInvalidDecl()) + return true; + ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); CXXRecordDecl *Pattern = 0; diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp new file mode 100644 index 0000000000..b3b7635106 --- /dev/null +++ b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp @@ -0,0 +1,16 @@ +// RUN: clang-cc -fsyntax-only -verify %s +template<int I, int J, class T> class X { + static const int value = 0; +}; + +template<int I, int J> class X<I, J, int> { + static const int value = 1; +}; + +template<int I> class X<I, I, int> { + static const int value = 2; +}; + +int array0[X<0, 0, float>::value == 0? 1 : -1]; +int array1[X<0, 1, int>::value == 1? 1 : -1]; +int array2[X<0, 0, int>::value == 2? 1 : -1]; |