Skip to content

Commit

Permalink
Added support for P0609: Attributes for Structured Bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasfertig committed Jan 12, 2025
1 parent b35ad86 commit ad96838
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5149,6 +5149,8 @@ void StructuredBindingsCodeGenerator::InsertArg(const BindingDecl* stmt)
type = stmt->getASTContext().getLValueReferenceType(type);
}

InsertAttributes(stmt->attrs());

mOutputFormatHelper.Append(GetQualifiers(*dyn_cast_or_null<VarDecl>(stmt->getDecomposedDecl())),
GetTypeNameAsParameter(type, GetName(*stmt)),
hlpAssing);
Expand Down
7 changes: 7 additions & 0 deletions tests/p0609Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// cmdline:-std=c++26

auto g() {
int ar[]{2,3,4};
auto [a, b [[maybe_unused]], c] = ar;
return a + c;
}
9 changes: 9 additions & 0 deletions tests/p0609Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
int g()
{
int ar[3] = {2, 3, 4};
int __ar5[3] = {ar[0], ar[1], ar[2]};
int & a = __ar5[0];
[[maybe_unused]] int & b = __ar5[1];
int & c = __ar5[2];
return a + c;
}

0 comments on commit ad96838

Please sign in to comment.