From 6680bf97904cc8b6ab7cc8cd1fb5af4482090ce4 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 3 Jun 2022 18:35:11 +0200 Subject: [PATCH] Fixed TODO_ASSERT --- lib/checkfunctions.cpp | 2 +- test/testfunctions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index ef80d237b..1bb300005 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -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); } diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index eb2285df7..bb2754b33 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -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());