From 3b5601dbeac7ec245a13c4bf4a9dcc6d33aac0f1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:41:48 +0200 Subject: [PATCH] Add tests for #9327, #10597 (#4566) * Add test for #9327 * Add test for #10597 --- test/testcondition.cpp | 9 +++++++++ test/testunusedvar.cpp | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index d35474d91..3157e68dc 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -4448,6 +4448,15 @@ private: " *n == 'A');\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(std::istringstream& i) {\n" // #9327 + " std::string s;\n" + " if (!(i >> s))\n" + " return;\n" + " if (!(i >> s))\n" + " return;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueSymbolic() diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index cdd247163..af675bcfa 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -3506,14 +3506,20 @@ private: ASSERT_EQUALS("", errout.str()); } - void localvar60() { // #10531 - functionVariableUsage("void Scale(double scale) {\n" + void localvar60() { + functionVariableUsage("void Scale(double scale) {\n" // #10531 " for (int i = 0; i < m_points.size(); ++i) {\n" " auto& p = m_points[i];\n" " p += scale;\n" " }\n" "}"); ASSERT_EQUALS("", errout.str()); + + functionVariableUsage("void foo(int c[]) {\n" // #10597 + " int& cc = c[0];\n" + " cc &= ~0xff;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void localvar61() { // #9407