-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) #89906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e87546f
d1e0f2e
618ba52
d98877f
eaf5a92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,7 +293,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, | |
|
||
void Declarator::setDecompositionBindings( | ||
SourceLocation LSquareLoc, | ||
ArrayRef<DecompositionDeclarator::Binding> Bindings, | ||
MutableArrayRef<DecompositionDeclarator::Binding> Bindings, | ||
SourceLocation RSquareLoc) { | ||
assert(!hasName() && "declarator given multiple names!"); | ||
|
||
|
@@ -317,7 +317,7 @@ void Declarator::setDecompositionBindings( | |
new DecompositionDeclarator::Binding[Bindings.size()]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note I'm not super fan of the hidden vector implementation here. |
||
BindingGroup.DeleteBindings = true; | ||
} | ||
std::uninitialized_copy(Bindings.begin(), Bindings.end(), | ||
std::uninitialized_move(Bindings.begin(), Bindings.end(), | ||
BindingGroup.Bindings); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,11 +102,21 @@ namespace PR33839 { | |
for (auto [x] : a) { // expected-warning {{unused variable '[x]'}} | ||
} | ||
} | ||
void use() { | ||
void use() { | ||
f<int>(); // expected-note {{instantiation of}} | ||
g<true>(); | ||
g<false>(); | ||
h<int>(); // expected-note {{instantiation of}} | ||
} | ||
} | ||
|
||
namespace maybe_unused_binding { | ||
|
||
void test() { | ||
struct X { int a, b; } x; | ||
auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute specifier sequence attached to a structured binding declaration is a C++2c extension}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any standard attributes other than this that make sense on SB's? If not, I'd like all of the standards ones tested to show what the behavior is (and 'not valid here' type errors are totally acceptable).
Additionally, we should do an audit of ALL our "C++" spelling attributes to see which make sense here and to make sure they are treated reasonably. I'm not asking to do that HERE, but a bug in our bug tracker (perhaps with a 'good starter bug' tag, particularly if we list ALL our attributes that need auditing) would be acceptable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I can add tests
We do not have this one
Yes, I can create an issue once we land that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a test to check the I've a question about this test case. We only add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is that test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree! |
||
} | ||
|
||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,7 @@ <h2 id="cxx26">C++2c implementation status</h2> | |
<tr> | ||
<td>Trivial infinite loops are not Undefined Behavior</td> | ||
<td><a href="https://wg21.link/P2809R3">P2809R3</a> (<a href="#dr">DR</a>)</td> | ||
<td class="none" align="center">No</td> | ||
<td class="unreleased" align="center">Clang 19</td> | ||
Comment on lines
188
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the wrong paper was marked as implemented There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix that shortly |
||
</tr> | ||
<tr> | ||
<td>Erroneous behaviour for uninitialized reads</td> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems causes the warning.
[-Wunused-but-set-variable]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that shortly