Author: Matheus Izvekov Date: 2021-09-08T14:09:00-07:00 New Revision: 02dece03f93d2ff847c3867e5f655793e29b2877
URL: https://github.com/llvm/llvm-project/commit/02dece03f93d2ff847c3867e5f655793e29b2877 DIFF: https://github.com/llvm/llvm-project/commit/02dece03f93d2ff847c3867e5f655793e29b2877.diff LOG: [clang] fix transformation of template arguments of 'auto' type constraints See PR48617. When assigning the new template arguments to the new TypeLoc, we were looping on the argument count of the original TypeLoc instead of the new one, which can be different when packs are present. Signed-off-by: Matheus Izvekov <mizve...@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D109406 (cherry picked from commit 68b9d8ed7abe4046992ae1557990edfbb3a772bc) Added: Modified: clang/lib/Sema/TreeTransform.h clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 70ba631dbfc6..d8a5b6ad4f94 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6578,7 +6578,7 @@ QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB, 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 index 7830d1f43526..494102742321 100644 --- 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 @@ namespace PR48593 { template<class> concept d = true; d<,> auto e = 0; // expected-error{{expected expression}} } + +namespace PR48617 { + template <typename...> concept C = true; + template <typename...> class A {}; + + template <typename... Ts> C<Ts...> auto e(A<Ts...>) { 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<int> auto e<int>(A<int>); + // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}} + // expected-note@-10 {{candidate template ignored: could not match 'C<int, Ts...> auto' against 'C<int> auto'}} + + template C<> auto e<>(A<>); + + template <typename... Ts> A<Ts...> c(Ts...); + int f = e(c(1, 2)); +} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits