Skip to content

Commit f5109df

Browse files
Add tests for #9822/#9823 (#5742)
1 parent 735831f commit f5109df

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/testunusedvar.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6574,6 +6574,25 @@ class TestUnusedVar : public TestFixture {
65746574
" return 0;\n"
65756575
"}\n");
65766576
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: a\n", errout.str());
6577+
6578+
functionVariableUsage("void f() {\n" // #9823
6579+
" auto cb = []() {\n"
6580+
" int i;\n"
6581+
" };\n"
6582+
" (void)cb;\n"
6583+
"}\n");
6584+
ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout.str());
6585+
6586+
functionVariableUsage("void f() {\n" // #9822
6587+
" int i;\n"
6588+
" auto cb = []() {\n"
6589+
" int i;\n"
6590+
" };\n"
6591+
" (void)cb;\n"
6592+
"}\n");
6593+
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: i\n"
6594+
"[test.cpp:4]: (style) Unused variable: i\n",
6595+
errout.str());
65776596
}
65786597

65796598

0 commit comments

Comments
 (0)