diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 17fa79095..43646c50d 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -250,7 +250,7 @@ void CheckFunctions::checkIgnoredReturnValue() else if (Token::Match(tok, "[(<]") && tok->link()) tok = tok->link(); - if (tok->varId() || !Token::Match(tok, "%name% (") || tok->isKeyword()) + if (tok->varId() || tok->isKeyword() || tok->isStandardType() || !Token::Match(tok, "%name% (")) continue; const Token *parent = tok->next()->astParent(); diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index ba12f4664..6563bae3d 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1310,7 +1310,7 @@ void CheckStl::negativeIndex() const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Scope * scope : symbolDatabase->functionScopes) { for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) { - if (!Token::Match(tok, "%var% [") || WRONG_DATA(!tok->next()->astOperand2(), tok)) + if (!Token::Match(tok, "%var% [") || !tok->next()->astOperand2()) continue; const Variable * const var = tok->variable(); if (!var || tok == var->nameToken()) diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 466616a26..9424f3103 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1826,6 +1826,7 @@ private: void checkLibraryMatchFunctions() { const auto settings_old = settings; settings.checkLibrary = true; + settings.daca = true; check("void f() {\n" " lib_func();" @@ -1992,6 +1993,11 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("void f() {\n" // #11604 + " int (*g)() = nullptr;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + settings = settings_old; } diff --git a/test/teststl.cpp b/test/teststl.cpp index 7808ed7fd..9766c0d1a 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -2319,6 +2319,16 @@ private: " return sum;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + const auto oldSettings = settings; + settings.daca = true; + + check("void f() {\n" + " const char a[][5] = { \"1\", \"true\", \"on\", \"yes\" };\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + settings = oldSettings; }