Fixed TODO_ASSERT

This commit is contained in:
orbitcowboy 2022-06-03 18:35:11 +02:00
parent d36e05af28
commit 6680bf9790
2 changed files with 2 additions and 2 deletions

View File

@ -130,7 +130,7 @@ void CheckFunctions::invalidFunctionUsage()
if (Token::Match(argtok, "& %var% !![") && argtok->next() && argtok->next()->valueType()) {
const ValueType * valueType = argtok->next()->valueType();
const Variable * variable = argtok->next()->variable();
if (valueType->type == ValueType::Type::CHAR && !variable->isArray() && !variable->isGlobal() &&
if (valueType->type == ValueType::Type::CHAR && !variable->isArray() && (variable->isConst() || !variable->isGlobal()) &&
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
}

View File

@ -579,7 +579,7 @@ private:
TODO_ASSERT_EQUALS("[test.cpp:9]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n", "", errout.str());
check("const char x = 'x'; size_t f() { return strlen(&x); }");
TODO_ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n", "", errout.str());
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n", errout.str());
check("const char x = 'x'; size_t f() { char y = x; return strlen(&y); }");
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n", errout.str());