diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 79817b3fb1ec3..bc16cfc67a24f 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2032,7 +2032,7 @@ void ASTDeclReader::ReadCXXDefinitionData( break; case LCK_ByCopy: case LCK_ByRef: - auto *Var = readDeclAs(); + auto *Var = readDeclAs(); SourceLocation EllipsisLoc = readSourceLocation(); new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc); ToCapture++; diff --git a/clang/test/Modules/pr72828.cppm b/clang/test/Modules/pr72828.cppm new file mode 100644 index 0000000000000..574523188507a --- /dev/null +++ b/clang/test/Modules/pr72828.cppm @@ -0,0 +1,24 @@ +// Test that we can handle capturing structured bindings. +// +// RUN: rm -fr %t +// RUN: mkdir %t +// +// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \ +// RUN: %s -emit-module-interface -o %t/m.pcm +// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \ +// RUN: -S -emit-llvm -disable-llvm-passes %t/m.pcm \ +// RUN: -o - | FileCheck %s + +export module m; + +struct s { + int m; +}; + +void f() { + auto [x] = s(); + [x] {}; +} + +// Check that we can generate the LLVM IR expectedly. +// CHECK: define{{.*}}@_ZGIW1m