diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 7759737b0..4faec0e63 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1699,7 +1699,7 @@ void CheckOther::checkIncompleteStatement() tok = tok->next()->link(); // C++11 struct/array/etc initialization in initializer list - else if (Token::Match(tok->previous(), "%var% {") && !Token::findsimplematch(tok,";",tok->link())) + else if (Token::Match(tok->previous(), "%var%|] {") && !Token::findsimplematch(tok,";",tok->link())) tok = tok->link(); // C++11 vector initialization / return { .. } diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 5ebf15199..d15b281d3 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -185,6 +185,14 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + // #6260 - C++11 array initialization + check("void foo() {\n" + " static const char* a[][2] {\n" + " {\"b\", \"\"},\n" + " };\n" + "}"); + ASSERT_EQUALS("", errout.str()); + // #2482 - false positive for empty struct check("struct A {};"); ASSERT_EQUALS("", errout.str());