Fixed #3690 (CppCheck is stuck on evaluating false preprocessor expression( = 0))

This commit is contained in:
Daniel Marjamäki 2012-07-13 11:28:45 +02:00
parent aa4fe3a1e2
commit e4ad193b40
2 changed files with 4 additions and 2 deletions

View File

@ -2569,8 +2569,9 @@ bool Preprocessor::validateCfg(const std::string &code, const std::string &cfg)
if (cfg[pos2] == ';')
macros.insert(cfg.substr(pos, pos2-pos));
pos = cfg.find(";", pos2);
if (pos != std::string::npos)
++pos;
if (pos == std::string::npos)
break;
++pos;
}
// check if any empty macros are used in code

View File

@ -3539,6 +3539,7 @@ private:
Settings settings;
Preprocessor preprocessor(&settings, this);
ASSERT_EQUALS(true, preprocessor.validateCfg("", "X=42")); // don't hang when parsing cfg
ASSERT_EQUALS(false, preprocessor.validateCfg("int x=X;", "X"));
ASSERT_EQUALS(false, preprocessor.validateCfg("X=1;", "X"));
ASSERT_EQUALS(true, preprocessor.validateCfg("int x=X;", "Y"));