Added a regression test for ticket 6928 - Improve check: unused variables, goto

This commit is contained in:
orbitcowboy 2022-03-07 10:12:57 +01:00
parent 3a5931b417
commit 1d2beb0431
1 changed files with 10 additions and 0 deletions

View File

@ -129,6 +129,7 @@ private:
TEST_CASE(localvar60); TEST_CASE(localvar60);
TEST_CASE(localvar61); // #9407 TEST_CASE(localvar61); // #9407
TEST_CASE(localvar62); // #10824 TEST_CASE(localvar62); // #10824
TEST_CASE(localvar63); // #6928
TEST_CASE(localvarloops); // loops TEST_CASE(localvarloops); // loops
TEST_CASE(localvaralias1); TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637 TEST_CASE(localvaralias2); // ticket #1637
@ -3362,6 +3363,15 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void localvar63() { // #6928
functionVariableUsage("void f(void) {\n"
" int x=3;\n" // <- set but not used
" goto y;\n"
" y:return;\n"
"}");
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is assigned a value that is never used.\n", errout.str());
}
void localvarloops() { void localvarloops() {
// loops // loops
functionVariableUsage("void fun(int c) {\n" functionVariableUsage("void fun(int c) {\n"