Fixed TODO_ASSERT
This commit is contained in:
parent
6680bf9790
commit
a74bb485b0
|
@ -130,7 +130,9 @@ void CheckFunctions::invalidFunctionUsage()
|
||||||
if (Token::Match(argtok, "& %var% !![") && argtok->next() && argtok->next()->valueType()) {
|
if (Token::Match(argtok, "& %var% !![") && argtok->next() && argtok->next()->valueType()) {
|
||||||
const ValueType * valueType = argtok->next()->valueType();
|
const ValueType * valueType = argtok->next()->valueType();
|
||||||
const Variable * variable = argtok->next()->variable();
|
const Variable * variable = argtok->next()->variable();
|
||||||
if (valueType->type == ValueType::Type::CHAR && !variable->isArray() && (variable->isConst() || !variable->isGlobal()) &&
|
if ( (valueType->type == ValueType::Type::CHAR|| (valueType->type == ValueType::Type::RECORD && Token::Match(argtok, "& %var% . %var% !!["))) &&
|
||||||
|
!variable->isArray() &&
|
||||||
|
(variable->isConst() || !variable->isGlobal()) &&
|
||||||
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
|
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
|
||||||
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
|
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,7 +576,8 @@ private:
|
||||||
" size_t l2 = strlen(&s2.x);\n"
|
" size_t l2 = strlen(&s2.x);\n"
|
||||||
" return l1 + l2;\n"
|
" return l1 + l2;\n"
|
||||||
"}");
|
"}");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:9]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n", "", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (error) Invalid strlen() argument nr 1. A nul-terminated string is required.\n"
|
||||||
|
"[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); }");
|
check("const char x = 'x'; size_t f() { return strlen(&x); }");
|
||||||
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());
|
||||||
|
|
Loading…
Reference in New Issue