File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2139,7 +2139,7 @@ void CheckOther::checkMisusedScopedObject()
21392139 return ;
21402140
21412141 auto getConstructorTok = [](const Token* tok, std::string& typeStr) -> const Token* {
2142- if (!Token::Match (tok, " [;{}] %name%" ))
2142+ if (!Token::Match (tok, " [;{}] %name%" ) || tok-> next ()-> isKeyword () )
21432143 return nullptr ;
21442144 tok = tok->next ();
21452145 typeStr.clear ();
Original file line number Diff line number Diff line change @@ -5648,6 +5648,12 @@ class TestOther : public TestFixture {
56485648 " [test.cpp:6]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n "
56495649 " [test.cpp:9]: (style) Instance of 'std::scoped_lock' object is destroyed immediately.\n " ,
56505650 errout.str ());
5651+
5652+ check (" struct S { int i; };\n "
5653+ " namespace {\n "
5654+ " S s() { return ::S{42}; }\n "
5655+ " }\n " , " test.cpp" );
5656+ ASSERT_EQUALS (" " , errout.str ());
56515657 }
56525658
56535659 void testMisusedScopeObjectAssignment () { // #11371
You can’t perform that action at this time.
0 commit comments