Skip to content

Commit ad96838

Browse files
committed
Added support for P0609: Attributes for Structured Bindings.
1 parent b35ad86 commit ad96838

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CodeGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5149,6 +5149,8 @@ void StructuredBindingsCodeGenerator::InsertArg(const BindingDecl* stmt)
51495149
type = stmt->getASTContext().getLValueReferenceType(type);
51505150
}
51515151

5152+
InsertAttributes(stmt->attrs());
5153+
51525154
mOutputFormatHelper.Append(GetQualifiers(*dyn_cast_or_null<VarDecl>(stmt->getDecomposedDecl())),
51535155
GetTypeNameAsParameter(type, GetName(*stmt)),
51545156
hlpAssing);

tests/p0609Test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// cmdline:-std=c++26
2+
3+
auto g() {
4+
int ar[]{2,3,4};
5+
auto [a, b [[maybe_unused]], c] = ar;
6+
return a + c;
7+
}

tests/p0609Test.expect

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
int g()
2+
{
3+
int ar[3] = {2, 3, 4};
4+
int __ar5[3] = {ar[0], ar[1], ar[2]};
5+
int & a = __ar5[0];
6+
[[maybe_unused]] int & b = __ar5[1];
7+
int & c = __ar5[2];
8+
return a + c;
9+
}

0 commit comments

Comments
 (0)