[PATCH] D119063: [SemaCXX] Properly scope ArgumentPackSubstitutionIndex when expanding base types
Michael Colavita via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 5 14:55:23 PST 2022
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119063.406213.patch
Type: text/x-patch
Size: 1581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220205/8c09787b/attachment.bin>
More information about the cfe-commits
mailing list