From 6f3131da8cd46e3c40841248ffeb13c7058ae1b2 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Tue, 23 Aug 2011 20:12:29 -0400 Subject: [PATCH] fix a serious symbol database bug where parts of a function could be skipped --- lib/symboldatabase.cpp | 2 +- test/testother.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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[]) {