File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1715,6 +1715,8 @@ bool Library::isnoreturn(const Token *ftok) const
17151715{
17161716 if (ftok->function () && ftok->function ()->isAttributeNoreturn ())
17171717 return true ;
1718+ if (ftok->variable () && ftok->variable ()->nameToken ()->isAttributeNoreturn ())
1719+ return true ;
17181720 if (isNotLibraryFunction (ftok)) {
17191721 if (Token::simpleMatch (ftok->astParent (), " ." )) {
17201722 const Token* contTok = ftok->astParent ()->astOperand1 ();
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ class TestLeakAutoVar : public TestFixture {
131131 TEST_CASE (exit1);
132132 TEST_CASE (exit2);
133133 TEST_CASE (exit3);
134+ TEST_CASE (exit4);
134135
135136 // handling function calls
136137 TEST_CASE (functioncall1);
@@ -1784,6 +1785,19 @@ class TestLeakAutoVar : public TestFixture {
17841785 ASSERT_EQUALS (" " , errout_str ());
17851786 }
17861787
1788+ void exit4 () {
1789+ check (" void __attribute__((__noreturn__)) (*func_notret)(void);\n "
1790+ " int main(int argc) {\n "
1791+ " void* ptr = malloc(1000);\n "
1792+ " if (argc == 1) {\n "
1793+ " free(ptr);\n "
1794+ " func_notret();\n "
1795+ " }\n "
1796+ " free(ptr);\n "
1797+ " }" );
1798+ ASSERT_EQUALS (" " , errout_str ());
1799+ }
1800+
17871801 void functioncall1 () {
17881802 check (" void f(struct S *p) {\n "
17891803 " p->x = malloc(10);\n "
You can’t perform that action at this time.
0 commit comments