Skip to content

Commit 3b5601d

Browse files
Add tests for #9327, #10597 (cppcheck-opensource#4566)
* Add test for #9327 * Add test for #10597
1 parent 4634a72 commit 3b5601d

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

test/testcondition.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,6 +4448,15 @@ class TestCondition : public TestFixture {
44484448
" *n == 'A');\n"
44494449
"}\n");
44504450
ASSERT_EQUALS("", errout.str());
4451+
4452+
check("void f(std::istringstream& i) {\n" // #9327
4453+
" std::string s;\n"
4454+
" if (!(i >> s))\n"
4455+
" return;\n"
4456+
" if (!(i >> s))\n"
4457+
" return;\n"
4458+
"}\n");
4459+
ASSERT_EQUALS("", errout.str());
44514460
}
44524461

44534462
void alwaysTrueSymbolic()

test/testunusedvar.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,14 +3506,20 @@ class TestUnusedVar : public TestFixture {
35063506
ASSERT_EQUALS("", errout.str());
35073507
}
35083508

3509-
void localvar60() { // #10531
3510-
functionVariableUsage("void Scale(double scale) {\n"
3509+
void localvar60() {
3510+
functionVariableUsage("void Scale(double scale) {\n" // #10531
35113511
" for (int i = 0; i < m_points.size(); ++i) {\n"
35123512
" auto& p = m_points[i];\n"
35133513
" p += scale;\n"
35143514
" }\n"
35153515
"}");
35163516
ASSERT_EQUALS("", errout.str());
3517+
3518+
functionVariableUsage("void foo(int c[]) {\n" // #10597
3519+
" int& cc = c[0];\n"
3520+
" cc &= ~0xff;\n"
3521+
"}\n");
3522+
ASSERT_EQUALS("", errout.str());
35173523
}
35183524

35193525
void localvar61() { // #9407

0 commit comments

Comments
 (0)