diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 94d250c75..9934ee133 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -591,7 +591,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti } else if (tok->str() == "{") { - if (!Token::Match(tok->previous(), "=|,|{")) + if (!Token::Match(tok->previous(), "=|,")) { scopeList.push_back(Scope(this, tok, scope, Scope::eUnconditional, tok)); scope = &scopeList.back(); diff --git a/test/testother.cpp b/test/testother.cpp index 468a6ebb3..8083b2ac0 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -41,6 +41,7 @@ private: TEST_CASE(zeroDiv2); TEST_CASE(zeroDiv3); TEST_CASE(zeroDiv4); + TEST_CASE(zeroDiv5); TEST_CASE(sprintf1); // Dangerous usage of sprintf TEST_CASE(sprintf2); @@ -354,6 +355,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void zeroDiv5() + { + check("void f()\n" + "{ { {\n" + " long a = b / 0;\n" + "} } }\n"); + ASSERT_EQUALS("[test.cpp:3]: (error) Division by zero\n", errout.str()); + } + void sprintfUsage(const char code[]) {