diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ac9b4dbba..f45d70f95 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1568,11 +1568,8 @@ void CheckOther::checkIncompleteStatement() return; for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { - if (tok->str() == "(") { + if (Token::Match(tok, "(|[")) tok = tok->link(); - if (Token::simpleMatch(tok, ") {") && Token::simpleMatch(tok->next()->link(), "} ;")) - tok = tok->next()->link(); - } else if (Token::simpleMatch(tok, "= {")) tok = tok->next()->link(); diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 54d41486f..e82ea529e 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -81,6 +81,7 @@ private: TEST_CASE(increment); // #3251 : FP for increment TEST_CASE(cpp11init); // #5493 : int i{1}; TEST_CASE(block); // ({ do_something(); 0; }) + TEST_CASE(mapindex); } void test1() { @@ -279,6 +280,13 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + void mapindex() { + check("void f() {\n" + " map[{\"1\",\"2\"}]=0;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestIncompleteStatement)