diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6578,7 +6578,7 @@ NewTL.setFoundDecl(TL.getFoundDecl()); NewTL.setLAngleLoc(TL.getLAngleLoc()); NewTL.setRAngleLoc(TL.getRAngleLoc()); - for (unsigned I = 0; I < TL.getNumArgs(); ++I) + for (unsigned I = 0; I < NewTL.getNumArgs(); ++I) NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo()); return Result; diff --git a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp --- a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp @@ -76,3 +76,25 @@ template concept d = true; d<,> auto e = 0; // expected-error{{expected expression}} } + +namespace PR48617 { + template concept C = true; + template class A {}; + + template C auto e(A) { return 0; } + + // FIXME: The error here does not make sense. + template auto e<>(A<>); + // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}} + // expected-note@-5 {{candidate template ignored: failed template argument deduction}} + + // FIXME: Should be able to instantiate this with no errors. + template C auto e(A); + // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}} + // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}} + + template C<> auto e<>(A<>); + + template A c(Ts...); + int f = e(c(1, 2)); +}