diff options
-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]; |