From df55ce14a031b0ef620470e69dc5ac3629d88dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 24 Feb 2013 10:00:03 +0100 Subject: [PATCH] Fixed #4503 (False positive: Incomplete statement (std::vector v{1};)) --- lib/checkother.cpp | 4 ++++ test/testincompletestatement.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 1c75a71b9..f1f56b5c1 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2257,6 +2257,10 @@ void CheckOther::checkIncompleteStatement() else if (tok->str() == "{" && Token::Match(tok->tokAt(-2), ",|: %var%") && Token::Match(tok->link(), "} [,{]")) tok = tok->link(); + // C++11 vector initialization + else if (Token::Match(tok,"> %var% {")) + tok = tok->linkAt(2); + else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num%")) { // No warning if numeric constant is followed by a "." or "," if (Token::Match(tok->next(), "%num% [,.]")) diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 36694cd8f..8b74a8fb3 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -167,7 +167,7 @@ private: } void structinit() { - // #2462 - C++0x struct initialization + // #2462 - C++11 struct initialization check("void f() {\n" " ABC abc{1,2,3};\n" "}\n"); @@ -180,6 +180,10 @@ private: // #4387 - C++11 initializer list check("A::A() : abc{0} {}"); ASSERT_EQUALS("", errout.str()); + + // #4503 - vector init + check("void f() { vector v{1}; }"); + ASSERT_EQUALS("", errout.str()); } void returnstruct() {