diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a591100f1..611947fcf 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1607,6 +1607,12 @@ private: return &tok; } + if (Token::Match(tok.previous(), "++|--") || Token::Match(tok.next(), "++|--")) + { + use(foundError, checks, &tok); + return &tok; + } + if (Token::Match(tok.previous(), "[;{}] %var% =")) { // using same variable rhs? diff --git a/test/testother.cpp b/test/testother.cpp index 66d70c00d..0a8813bfb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1076,6 +1076,13 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str()); + checkUninitVar("void f()\n" + "{\n" + " int a;\n" + " a++;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str()); + checkUninitVar("static void foo()\n" "{\n" " int i;\n"