Add tests for #9822/#9823 (#5742)

This commit is contained in:
chrchr-github 2023-12-08 21:20:10 +01:00 committed by GitHub
parent 735831fc54
commit f5109df632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -6574,6 +6574,25 @@ private:
" return 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: a\n", errout.str());
functionVariableUsage("void f() {\n" // #9823
" auto cb = []() {\n"
" int i;\n"
" };\n"
" (void)cb;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (style) Unused variable: i\n", errout.str());
functionVariableUsage("void f() {\n" // #9822
" int i;\n"
" auto cb = []() {\n"
" int i;\n"
" };\n"
" (void)cb;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) Unused variable: i\n"
"[test.cpp:4]: (style) Unused variable: i\n",
errout.str());
}