Skip to content

Commit 11070a8

Browse files
committed
add test
1 parent 2abd7da commit 11070a8

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/testunusedvar.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

72027218
REGISTER_TEST(TestUnusedVar)

0 commit comments

Comments
 (0)