Skip to content

Commit c1fc2d8

Browse files
Update testother.cpp
1 parent 4be28f0 commit c1fc2d8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/testother.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class TestOther : public TestFixture {
121121
TEST_CASE(varScope41); // #11845
122122
TEST_CASE(varScope42);
123123
TEST_CASE(varScope43);
124+
TEST_CASE(varScope45);
124125

125126
TEST_CASE(oldStylePointerCast);
126127
TEST_CASE(intToPointerCast);
@@ -1945,6 +1946,17 @@ class TestOther : public TestFixture {
19451946
ASSERT_EQUALS("[test.cpp:3:12]: (style) The scope of the variable 'x' can be reduced. [variableScope]\n", errout_str());
19461947
}
19471948

1949+
varScope45() {
1950+
check("void g(int x, int y) {\n" // #14497
1951+
" int a = x, b = y;\n"
1952+
" if (a) {}\n"
1953+
" else {\n"
1954+
" if (b) {}\n"
1955+
" }\n"
1956+
"}\n");
1957+
ASSERT_EQUALS("[test.cpp:2:16]: (style) The scope of the variable 'b' can be reduced. [variableScope]\n", errout_str());
1958+
}
1959+
19481960
#define checkOldStylePointerCast(...) checkOldStylePointerCast_(__FILE__, __LINE__, __VA_ARGS__)
19491961
template<size_t size>
19501962
void checkOldStylePointerCast_(const char* file, int line, const char (&code)[size], Standards::cppstd_t std = Standards::CPPLatest) {

0 commit comments

Comments
 (0)