colavitam updated this revision to Diff 406213. colavitam added a comment. Fix comments for new test case.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119063/new/ https://reviews.llvm.org/D119063 Files: clang/lib/Sema/SemaTemplateInstantiate.cpp clang/test/SemaCXX/template-base-class-pack-expansion.cpp Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s +// Don't crash (#53609). + +// expected-no-diagnostics + +template <class, int> struct a; + +template <class, class...> struct b; +template <class x, class... y, y... z> +struct b<x, a<y, z>...> {}; + +template <class... x> struct c: b<x>... {}; + +c<int> d; Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2530,12 +2530,13 @@ // If we should expand this pack expansion now, do so. if (ShouldExpand) { for (unsigned I = 0; I != *NumExpansions; ++I) { + { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I); - TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(), - TemplateArgs, - Base.getSourceRange().getBegin(), - DeclarationName()); + BaseTypeLoc = + SubstType(Base.getTypeSourceInfo(), TemplateArgs, + Base.getSourceRange().getBegin(), DeclarationName()); + } if (!BaseTypeLoc) { Invalid = true; continue;
Index: clang/test/SemaCXX/template-base-class-pack-expansion.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/template-base-class-pack-expansion.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s +// Don't crash (#53609). + +// expected-no-diagnostics + +template <class, int> struct a; + +template <class, class...> struct b; +template <class x, class... y, y... z> +struct b<x, a<y, z>...> {}; + +template <class... x> struct c: b<x>... {}; + +c<int> d; Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2530,12 +2530,13 @@ // If we should expand this pack expansion now, do so. if (ShouldExpand) { for (unsigned I = 0; I != *NumExpansions; ++I) { + { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, I); - TypeSourceInfo *BaseTypeLoc = SubstType(Base.getTypeSourceInfo(), - TemplateArgs, - Base.getSourceRange().getBegin(), - DeclarationName()); + BaseTypeLoc = + SubstType(Base.getTypeSourceInfo(), TemplateArgs, + Base.getSourceRange().getBegin(), DeclarationName()); + } if (!BaseTypeLoc) { Invalid = true; continue;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits