diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -370,7 +370,8 @@ case Template: case TemplateExpansion: - return TemplateArg.Name == Other.TemplateArg.Name && + return getAsTemplateOrTemplatePattern().getAsTemplateDecl() == + Other.getAsTemplateOrTemplatePattern().getAsTemplateDecl() && TemplateArg.NumExpansions == Other.TemplateArg.NumExpansions; case Declaration: diff --git a/clang/test/CXX/dcl/dcl.fct/p17.cpp b/clang/test/CXX/dcl/dcl.fct/p17.cpp --- a/clang/test/CXX/dcl/dcl.fct/p17.cpp +++ b/clang/test/CXX/dcl/dcl.fct/p17.cpp @@ -257,4 +257,23 @@ static_assert(is_same_v); // expected-error@-1{{no matching}} static_assert(is_same_v); -} + + // clang-format off + template struct S3 {}; + // expected-note@-1 {{'S3' declared here}} + // expected-note@-2 {{template is declared here}} + void f23(C2<::S3> auto); + // expected-error@-1 {{no template named 'S3' in the global namespace; did you mean simply 'S3'?}} + // expected-error@-2 {{use of class template '::S3' requires template arguments}} + // clang-format on +} // namespace constrained + +template struct S4 {}; +// expected-note@-1 {{template is declared here}} + +namespace constrained { +// clang-format off +void f24(C2<::S4> auto); +// expected-error@-1 {{use of class template '::S4' requires template arguments}} +// clang-format on +} // namespace constrained