Skip to content

Commit 0e5fe29

Browse files
author
git apple-llvm automerger
committed
Merge commit '7a94acb2da5b' from llvm.org/main into next
2 parents 3f03577 + 7a94acb commit 0e5fe29

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

clang/lib/AST/TypePrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,10 +1199,10 @@ void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) {
11991199

12001200
void TypePrinter::printPackIndexingBefore(const PackIndexingType *T,
12011201
raw_ostream &OS) {
1202-
if (T->isInstantiationDependentType())
1203-
OS << T->getPattern() << "...[" << T->getIndexExpr() << "]";
1204-
else
1202+
if (T->hasSelectedType())
12051203
OS << T->getSelectedType();
1204+
else
1205+
OS << T->getPattern() << "...[" << T->getIndexExpr() << "]";
12061206
spaceBeforePlaceHolder(OS);
12071207
}
12081208

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: not %clang_cc1 -std=c++2c -ast-dump %s | FileCheck %s
2+
3+
namespace InvalidPacksShouldNotCrash {
4+
5+
struct NotAPack;
6+
template <typename T, auto V, template<typename> typename Tp>
7+
void not_pack() {
8+
int i = 0;
9+
i...[0]; // expected-error {{i does not refer to the name of a parameter pack}}
10+
V...[0]; // expected-error {{V does not refer to the name of a parameter pack}}
11+
NotAPack...[0] a; // expected-error{{'NotAPack' does not refer to the name of a parameter pack}}
12+
T...[0] b; // expected-error{{'T' does not refer to the name of a parameter pack}}
13+
Tp...[0] c; // expected-error{{'Tp' does not refer to the name of a parameter pack}}
14+
}
15+
16+
// CHECK: FunctionDecl {{.*}} not_pack 'void ()'
17+
// CHECK: DeclStmt {{.*}}
18+
// CHECK: DeclStmt {{.*}}
19+
// CHECK-NEXT: VarDecl {{.*}} a 'NotAPack...{{.*}}'
20+
// CHECK-NEXT: DeclStmt {{.*}}
21+
// CHECK-NEXT: VarDecl {{.*}} 'T...{{.*}}'
22+
// CHECK-NEXT: DeclStmt {{.*}}
23+
// CHECK-NEXT: VarDecl {{.*}} c 'Tp...{{.*}}'
24+
25+
}

0 commit comments

Comments
 (0)