Skip to content

Commit 649e811

Browse files
committed
[C++20] [Modules] Handling capturing strucuted bindings
Close #72828. This should be an overlook that we extend the type of captures but we forgot to fix it in deserializer side.
1 parent e399a31 commit 649e811

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
20322032
break;
20332033
case LCK_ByCopy:
20342034
case LCK_ByRef:
2035-
auto *Var = readDeclAs<VarDecl>();
2035+
auto *Var = readDeclAs<ValueDecl>();
20362036
SourceLocation EllipsisLoc = readSourceLocation();
20372037
new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
20382038
ToCapture++;

clang/test/Modules/pr72828.cppm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Test that we can handle capturing structured bindings.
2+
//
3+
// RUN: rm -fr %t
4+
// RUN: mkdir %t
5+
//
6+
// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \
7+
// RUN: %s -emit-module-interface -o %t/m.pcm
8+
// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \
9+
// RUN: -S -emit-llvm -disable-llvm-passes %t/m.pcm \
10+
// RUN: -o - | FileCheck %s
11+
12+
export module m;
13+
14+
struct s {
15+
int m;
16+
};
17+
18+
void f() {
19+
auto [x] = s();
20+
[x] {};
21+
}
22+
23+
// Check that we can generate the LLVM IR expectedly.
24+
// CHECK: define{{.*}}@_ZGIW1m

0 commit comments

Comments
 (0)