diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index b06b9b16d..fbaed531e 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -305,7 +305,9 @@ static void checkExecutionPaths_(const Token *tok, std::list &c } // might be a noreturn function.. - if (Token::Match(tok->previous(), "[;{}] %var% ( ) ; }") && tok->varId() == 0) + if (tok->varId() == 0 && + (Token::Match(tok->previous(), "[;{}] %var% ( ) ; }") || + Token::Match(tok->previous(), "[;{}] %var% ( %num% ) ; }"))) { ExecutionPath::bailOut(checks); return; diff --git a/test/testother.cpp b/test/testother.cpp index 1e87ef996..59ca0c885 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2353,6 +2353,27 @@ private: " f();\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str()); + + // calling noreturn function.. + checkUninitVar("int foo(int a) {\n" + " int x;\n" + " if (a==1)\n" + " g();\n" // might be a noreturn function + " else\n" + " x = 3;\n" + " return x;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + + checkUninitVar("int foo(int a) {\n" + " int x;\n" + " if (a==1)\n" + " g(1);\n" // might be a noreturn function + " else\n" + " x = 3;\n" + " return x;\n" + "}"); + ASSERT_EQUALS("", errout.str()); }