Improve check for wchar_t (#4285)
This commit is contained in:
parent
109a031ec7
commit
b16d12b5fb
|
@ -130,7 +130,7 @@ 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 || (valueType->type == ValueType::Type::RECORD && Token::Match(argtok, "& %var% . %var% ,|)"))) &&
|
if ((valueType->type == ValueType::Type::CHAR || valueType->type == ValueType::Type::WCHAR_T || (valueType->type == ValueType::Type::RECORD && Token::Match(argtok, "& %var% . %var% ,|)"))) &&
|
||||||
!variable->isArray() &&
|
!variable->isArray() &&
|
||||||
(variable->isConst() || !variable->isGlobal()) &&
|
(variable->isConst() || !variable->isGlobal()) &&
|
||||||
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
|
(!argtok->next()->hasKnownValue() || argtok->next()->getValue(0) == nullptr)) {
|
||||||
|
|
|
@ -745,6 +745,9 @@ private:
|
||||||
" s[strlen(s)] = ' ';\n"
|
" s[strlen(s)] = ' ';\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("size_t f() { wchar_t x = L'x'; return wcslen(&x); }");
|
||||||
|
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid wcslen() argument nr 1. A nul-terminated string is required.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mathfunctionCall_sqrt() {
|
void mathfunctionCall_sqrt() {
|
||||||
|
|
Loading…
Reference in New Issue