diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index bfab41b7e4deab..5c24649044856a 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -2025,6 +2025,16 @@ static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg, } } + if (Arg.getKind() == TemplateArgument::Integral && + Pattern.getKind() == TemplateArgument::Expression) { + Expr const *expr = Pattern.getAsExpr(); + + if (!expr->isValueDependent() && expr->isIntegerConstantExpr(Ctx)) { + return llvm::APSInt::isSameValue(expr->EvaluateKnownConstInt(Ctx), + 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 index 0c555b53f95e63..51489c5eac5adf 100644 --- 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> eA; 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