Fix FP misusedScopedObject (#5321)
This commit is contained in:
parent
5371455606
commit
466da1e77a
|
@ -2139,7 +2139,7 @@ void CheckOther::checkMisusedScopedObject()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto getConstructorTok = [](const Token* tok, std::string& typeStr) -> const Token* {
|
auto getConstructorTok = [](const Token* tok, std::string& typeStr) -> const Token* {
|
||||||
if (!Token::Match(tok, "[;{}] %name%"))
|
if (!Token::Match(tok, "[;{}] %name%") || tok->next()->isKeyword())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
typeStr.clear();
|
typeStr.clear();
|
||||||
|
|
|
@ -5648,6 +5648,12 @@ private:
|
||||||
"[test.cpp:6]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n"
|
"[test.cpp:6]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n"
|
||||||
"[test.cpp:9]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n",
|
"[test.cpp:9]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
check("struct S { int i; };\n"
|
||||||
|
"namespace {\n"
|
||||||
|
" S s() { return ::S{42}; }\n"
|
||||||
|
"}\n", "test.cpp");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testMisusedScopeObjectAssignment() { // #11371
|
void testMisusedScopeObjectAssignment() { // #11371
|
||||||
|
|
Loading…
Reference in New Issue