From 58c2f372b955a65e6008de4d2baaecc310dd78de Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 22 Mar 2014 19:55:13 +0100 Subject: [PATCH] Fixed false positive when noreturn function is defined (#5601, second attempt) --- lib/checkother.cpp | 2 +- test/testother.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 1d5e6be3c..171a69c12 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1609,7 +1609,7 @@ void CheckOther::checkUnreachableCode() secondBreak = tok->tokAt(3); labelName = tok->next(); } else if (Token::Match(tok, "%var% (") && _settings->library.isnoreturn(tok->str())) { - if (!tok->function() || (tok->function()->token != tok && tok->function()->tokenDef != tok)) + if ((!tok->function() || (tok->function()->token != tok && tok->function()->tokenDef != tok)) && tok->linkAt(1)->strAt(1) != "{") secondBreak = tok->linkAt(1)->tokAt(2); } diff --git a/test/testother.cpp b/test/testother.cpp index 11be446da..f0ad3b538 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2871,6 +2871,12 @@ private: "}", 0, false, false, false, false, &settings); ASSERT_EQUALS("", errout.str()); + check("void NeonSession::exit()\n" + "{\n" + " SAL_INFO(\"ucb.ucp.webdav\", \"neon commands cannot be aborted\");\n" + "}", 0, false, false, false, false, &settings); + ASSERT_EQUALS("", errout.str()); + check("void foo(int a)\n" "{\n" " switch(a) {\n"