Fix FP knownArgument (f'up to #11927) (#5434)

This commit is contained in:
chrchr-github 2023-09-11 20:02:00 +02:00 committed by GitHub
parent 9b3b477765
commit 1b5b74d1f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -3737,7 +3737,7 @@ void CheckOther::checkKnownArgument()
continue; continue;
if (!Token::Match(tok->astParent(), "(|{|,")) if (!Token::Match(tok->astParent(), "(|{|,"))
continue; continue;
if (tok->astParent()->isCast()) if (tok->astParent()->isCast() || (tok->isCast() && Token::Match(tok->astOperand2(), "++|--|%assign%")))
continue; continue;
int argn = -1; int argn = -1;
const Token* ftok = getTokenArgumentFunction(tok, argn); const Token* ftok = getTokenArgumentFunction(tok, argn);

View File

@ -635,7 +635,7 @@ static void setTokenValue(Token* tok,
// Ensure that the comma isn't a function call // Ensure that the comma isn't a function call
if (!callParent || (!Token::Match(callParent->previous(), "%name%|> (") && !Token::simpleMatch(callParent, "{") && if (!callParent || (!Token::Match(callParent->previous(), "%name%|> (") && !Token::simpleMatch(callParent, "{") &&
(!Token::Match(callParent, "( %name%") || settings->library.isNotLibraryFunction(callParent->next())) && (!Token::Match(callParent, "( %name%") || settings->library.isNotLibraryFunction(callParent->next())) &&
!(callParent->str() == "(" && (Token::simpleMatch(callParent->astOperand1(), "*") || Token::Match(callParent->astOperand1(), "%name%"))))) { !(callParent->str() == "(" && (Token::simpleMatch(callParent->astOperand1(), "*") || Token::Match(callParent->astOperand1(), "%name%|("))))) {
setTokenValue(parent, std::move(value), settings); setTokenValue(parent, std::move(value), settings);
return; return;
} }

View File

@ -11074,6 +11074,17 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("struct S { void operator()(int, int); };\n"
"void f(int i) {\n"
" S()(i, 1);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(int& r) {\n"
" g(static_cast<char>(r = 42));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct S { int i; };\n" check("struct S { int i; };\n"
"void f(int i) {\n" "void f(int i) {\n"
" const int a[] = { i - 1 * i, 0 };\n" " const int a[] = { i - 1 * i, 0 };\n"