diff --git a/clang/lib/AST/TemplateUtils.cpp b/clang/lib/AST/TemplateUtils.cpp --- a/clang/lib/AST/TemplateUtils.cpp +++ b/clang/lib/AST/TemplateUtils.cpp @@ -106,6 +106,20 @@ } } + if (Arg.getKind() == TemplateArgument::Integral && + Pattern.getKind() == TemplateArgument::Expression) { + Expr const *expr = Pattern.getAsExpr(); + + if (!expr->isValueDependent()) { + Expr::EvalResult Result; + expr->EvaluateAsConstantExpr(Result, Ctx); + if (Result.Val.isInt()) { + return llvm::APSInt::isSameValue(Result.Val.getInt(), + Arg.getAsIntegral()); + } + } + } + if (Arg.getKind() != Pattern.getKind()) return false; diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp --- a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp @@ -15,7 +15,7 @@ eval> eB; eval> eC; // expected-error{{implicit instantiation of undefined template 'eval>'}} eval> eD; // expected-error{{implicit instantiation of undefined template 'eval>'}} -eval> eE; // expected-error{{implicit instantiation of undefined template 'eval>}} +eval> eE; // expected-error{{implicit instantiation of undefined template 'eval>}} template