File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -259,6 +259,8 @@ class TestUnusedVar : public TestFixture {
259259 TEST_CASE (escapeAlias); // #9150
260260 TEST_CASE (volatileData); // #9280
261261 TEST_CASE (globalData);
262+
263+ TEST_CASE (structuredBinding); // #13269
262264 }
263265
264266 struct FunctionVariableUsageOptions
@@ -7197,6 +7199,20 @@ class TestUnusedVar : public TestFixture {
71977199 " }" );
71987200 ASSERT_EQUALS (" " , errout_str ());
71997201 }
7202+
7203+ void structuredBinding () { // #13269
7204+ functionVariableUsage (" int main()\n "
7205+ " {\n "
7206+ " auto [a0, b1] = std::make_pair(42, 0.42);\n "
7207+ " [[maybe_unused]] auto [a2, b3] = std::make_pair(42, 0.42);\n "
7208+ " auto [a4, b5] = std::make_pair(42, 0.42);\n "
7209+ " (void) b5;\n "
7210+ " }\n " );
7211+
7212+ ASSERT_EQUALS (" [test.cpp:3:19]: (style) Variable 'a0' is assigned a value that is never used. [unreadVariable]\n "
7213+ " [test.cpp:3:19]: (style) Variable 'b1' is assigned a value that is never used. [unreadVariable]\n "
7214+ " [test.cpp:5:19]: (style) Variable 'a4' is assigned a value that is never used. [unreadVariable]\n " , errout_str ());
7215+ }
72007216};
72017217
72027218REGISTER_TEST (TestUnusedVar)
You can’t perform that action at this time.
0 commit comments